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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the VBA syntax that says:

Status
Not open for further replies.

striker73

MIS
Jun 7, 2001
376
US
What is the VBA syntax that says:

If MyWordDoc.doc is open Then <--How do I say this??
'Don't open it again
Else
Set objWord = GetObject(FilePath, &quot;Word.Document&quot;)
objWord.Application.Visible = True
End If



Thanks!!!




 
Try....
exp : strName = c:\MyWordDoc.doc
If strname.IsOpen Then <--How do I say this??
'Don't open it again
Else
Set objWord = GetObject(FilePath, &quot;Word.Document&quot;)
objWord.Application.Visible = True
End If
 
That doesn't seem to work. I have a string variable called FilePath that is equal to &quot;C:\MyWordDoc.doc&quot; and I get an &quot;invalid qualifier&quot; when I try to use FilePath.IsOpen. I have been looking everywhere for an answer and haven't found a good solution. :(
 

Instaciate Word first just using the New keyword, then loop through the Documents collection of the Aplication object to check & see if the documents open

With objWord.Application

For Each Doc In Documents
If .name = (YourName&quot;) then
'do something
Else
Set objWord = GetObject(FilePath, &quot;Word.Document&quot;)
objWord.Application.Visible = True
End If
Next Doc
 
I understand the logic, but what is the VBA syntax? Thanks

If Word is open
Loop through open documents
If document.name = FilePath Then
Bool Found = True
End if
Next Doc
End if

If (Found = True) Then
Don't open the file
Else
Open the file
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top