Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / July 2005

Tip: Looking for answers? Try searching our database.

How to tell if word is already running

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JWS315 - 28 Jul 2005 18:55 GMT
How can I tell if an instance of Word is already running from Access so that
I can issue a message to the user to close Word before they run my report?

Thanks
Jerry
Dirk Goldgar - 28 Jul 2005 20:08 GMT
> How can I tell if an instance of Word is already running from Access
> so that I can issue a message to the user to close Word before they
> run my report?

One way is described at this link:

   http://www.mvps.org/access/api/api0007.htm
   API: Find out if an application is currently running

Another way would be to try to get a reference to the Word application
object, and see if you succeed:

   Dim oWord As Object

   On Error Resume Next
   Set oWord = GetObject(, "Word.Application")
   If Err.Number = 0 Then
       Set oWord = Nothing
       MsgBox "Word is running;  please close it."
   End If

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

JWS315 - 28 Jul 2005 20:20 GMT
Dirk - Thanks!

One additional question, If I find it is running can I issue a quit command
(oWord.Quit) to close the running instance before continuing my code?  Will
this allow the user to either save the current document or will it just close
Word without offering a save as dialog?

TFH! - Jerry

> > How can I tell if an instance of Word is already running from Access
> > so that I can issue a message to the user to close Word before they
[quoted text clipped - 16 lines]
>         MsgBox "Word is running;  please close it."
>     End If
Dirk Goldgar - 28 Jul 2005 20:41 GMT
> Dirk - Thanks!
>
> One additional question, If I find it is running can I issue a quit
> command (oWord.Quit) to close the running instance before continuing
> my code?  Will this allow the user to either save the current
> document or will it just close Word without offering a save as dialog?

I just tested it with the following code:

   Dim oWord As Object

   On Error Resume Next
   Set oWord = GetObject(, "Word.Application")
   If Err.Number = 0 Then
       oWord.Activate
       oWord.Quit
       Set oWord = Nothing
   End If

Word prompted me to save the document.  However, the dialog box also
allowed me to Cancel the save, so you may need to program around that.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

JWS315 - 28 Jul 2005 21:04 GMT
Great - I will give this a try - thanks for the Help!  Jerry

> > Dirk - Thanks!
> >
[quoted text clipped - 17 lines]
> Word prompted me to save the document.  However, the dialog box also
> allowed me to Cancel the save, so you may need to program around that.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.