I am using the code below to detect word (MyWordApp is a global variable):
Public Sub StartWord()
On Error GoTo Err_StartWord
Dim wrdTmp As Word.Application
'On Error Resume Next
Set wrdTmp = GetObject(, "Word.Application"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
If Err.number <> 0 Then Set wrdTmp = CreateObject("Word.Application"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Set myWordApp = wrdTmp
myWordApp.Application.Visible = True
Debug.Print "word was already running"
Exit_StartWord:
Exit Sub
Err_StartWord:
' err.number for word running but not able to be visible is 462
Debug.Print Err.number
Debug.Print "No word running or won't be visible"
'MsgBox Err.Description
Set myWordApp = CreateObject("Word.Application"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
myWordApp.Application.Visible = True
Resume Exit_StartWord
End Sub
I am basically running a database in Access, which uses word to run mailmerges. In short, the speed to load up word is a significant part of the time to run the mailmerge and *lots* of small mail merges are needed by the users, hence I link to an instance of word already open.
As I am sure you have guessed, this creates problems and word occasionally crashes. I have noticed that this always seems to be when Outlook has a message open and is using Word to edit it.
Any ideas why this should happen? Is there a way to detect whether an outlook message is open and using Word to edit it (on those ocassions I could just start a new version of word)
Any help would be much appreciated - so far all I've been able to say to users is don't use Word to edit emails (and am fairly unpopular for that)
Public Sub StartWord()
On Error GoTo Err_StartWord
Dim wrdTmp As Word.Application
'On Error Resume Next
Set wrdTmp = GetObject(, "Word.Application"
If Err.number <> 0 Then Set wrdTmp = CreateObject("Word.Application"
Set myWordApp = wrdTmp
myWordApp.Application.Visible = True
Debug.Print "word was already running"
Exit_StartWord:
Exit Sub
Err_StartWord:
' err.number for word running but not able to be visible is 462
Debug.Print Err.number
Debug.Print "No word running or won't be visible"
'MsgBox Err.Description
Set myWordApp = CreateObject("Word.Application"
myWordApp.Application.Visible = True
Resume Exit_StartWord
End Sub
I am basically running a database in Access, which uses word to run mailmerges. In short, the speed to load up word is a significant part of the time to run the mailmerge and *lots* of small mail merges are needed by the users, hence I link to an instance of word already open.
As I am sure you have guessed, this creates problems and word occasionally crashes. I have noticed that this always seems to be when Outlook has a message open and is using Word to edit it.
Any ideas why this should happen? Is there a way to detect whether an outlook message is open and using Word to edit it (on those ocassions I could just start a new version of word)
Any help would be much appreciated - so far all I've been able to say to users is don't use Word to edit emails (and am fairly unpopular for that)