GeekGirlau
Programmer
AAAARRRRRGGGHHHHH!!!!!!!!!
I'm having constant fun and games using CreateObject and GetObject. In the following sample, if Word is not running I get error 429, but Word is not being launched.
As soon as I reach the ".Documents.Add" I get error 91 - object not set. I can use Shell to launch Word, however GetObject still won't capture the running instance of Word!!
Any ideas for a bullet-proof activation method before I go insane?? X-)
Dim objWord as Word.Application
dim x
On Error Resume Next
Set objWord = CreateObject("Word.Application"
If Err.Number = 429 Then
Set objWord = New Word.Application
End If
On Error GoTo AutoError
With objWord
.Documents.Open FileName:=strExportFile
<more code here>
.Quit
End With
AutoExit:
On Error Resume Next
Set objWord = Nothing
Exit Sub
AutoError:
Select Case Err.Number
Case 91
Err.Clear
x = Shell("winword.exe", vbNormalFocus)
AppActivate x
Set objWord = GetObject(, "Word.Application"
Resume
Case Else
MsgBox Err.Number & ": " & Err.Description
resume AutoExit
End Select
I'm having constant fun and games using CreateObject and GetObject. In the following sample, if Word is not running I get error 429, but Word is not being launched.
As soon as I reach the ".Documents.Add" I get error 91 - object not set. I can use Shell to launch Word, however GetObject still won't capture the running instance of Word!!
Any ideas for a bullet-proof activation method before I go insane?? X-)
Dim objWord as Word.Application
dim x
On Error Resume Next
Set objWord = CreateObject("Word.Application"
If Err.Number = 429 Then
Set objWord = New Word.Application
End If
On Error GoTo AutoError
With objWord
.Documents.Open FileName:=strExportFile
<more code here>
.Quit
End With
AutoExit:
On Error Resume Next
Set objWord = Nothing
Exit Sub
AutoError:
Select Case Err.Number
Case 91
Err.Clear
x = Shell("winword.exe", vbNormalFocus)
AppActivate x
Set objWord = GetObject(, "Word.Application"
Resume
Case Else
MsgBox Err.Number & ": " & Err.Description
resume AutoExit
End Select