Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking for a specific document is open in a Word macro?

Status
Not open for further replies.

GZook

Programmer
Apr 14, 2003
42
US
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 ?
 
Create the following Function :

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 .............

A.C.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top