Function to test if an application and file is open (1 Viewer)

R

rswensen

Guest
While searching the Microsoft KB I found a function or method which will return the name of open applications on the Windows desktop. Do any of you know what that is? Using automation I am trying to start MS Word in Access and want to test to see if the application is running and if the desired file is already open.

Thanks in advance.

Ron Swensen
 

Keith P

Registered User.
Local time
Today, 08:36
Joined
Oct 11, 2000
Messages
122
You could try GetObject to see if Word is already open and test for an error response. If error (I think 429) Word is not open then create a new Word application, e.g.

Set WordApp = GetObject(,"Word Application")
If err = 429 then
Set WordApp = New Word.Application

Similarly you could try to open the file, e.g. WordApp.Documents.Open filename:="myFileName" and test for any error response to see if it is already open.

Hope this helps
 

Keith P

Registered User.
Local time
Today, 08:36
Joined
Oct 11, 2000
Messages
122
Further to my earlier posting. I use this method where I want to do other things with Word, each create document, template, populate with data. If you wish simply to open an existing Word document then set and follow a hyperlink address with the full path of the document, e.g. C:\MyFolder\MyDocument.doc
 

Users who are viewing this thread

Top Bottom