At the beginning of my Word macro, I would like to have a simple If structure to determine that the correct document is open before continuing with macro processing, maybe by checking the file name. How can this be done ?
Function IsDocOpen(strDocName)
Dim oDoc As Document
For Each oDoc In Documents
If oDoc.Name = strDocName Then
IsDocOpen = True
Else
IsDocOpen = False
End If
Next oDoc
End Function
You can then use
If IsDocOpen("Correct.doc" then
' Do process .............
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.