Hi allm
Sorry for not having any sample code already. I'm looking for a way to close a word document that I know if open based on the file name of that document.
I have the following code to check whether the document is open, I'm stuck on the next step of how to automatically close it.
Trailing slash is just a bit of code that ensures that the string entered is followed by a trailing slashCode:Public Function FileIsOpen(sPath As String, sName As String) As Boolean Dim ff As Long ' Set the name of the full path sWordDoc = TrailingSlash(sPath) & sName On Error Resume Next ff = FreeFile() Open sWordDoc For Input Lock Read As #ff Close ff FileIsOpen = (Err.Number <> 0) On Error GoTo 0 End Function