Office Automation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've created a documentation database for documenting Health Systems
interfaces in a 22 hospital organization. The nterface folks fill out a MS
Word document based on a MS Word tempate I created. From Access I have the
below code. The code generates a R$un time error, NOT deferred by ON ERROR
RESUME NEXT, "429" "ActiveX can't create Object". Anyone have any ideas on
this? I've tried everything I can think of. My code is right out of the help
files with needed adjustments... Any help would be appreciated :-)

Private Sub Command239_Click()
Dim Pptr As Object, cntr1 As Integer, cntr2 As Integer, Tptr As Object
Dim filpth As String, FileName As String, Fullpth As String, prop As Variant
Dim WordWasNotRunning As Boolean ' Flag for final release.


DoCmd.OpenForm "Word Import", acNormal, , , acFormEdit, acDialog
filpth = Forms![BldReportFrm].pthstring
FileName = Forms![BldReportFrm].FileName
Fullpth = filpth & "\" & FileName

On Error Resume Next ' Defer error handling.
Set Pptr = GetObject(, "Word.Application")
If Err.Number <> 0 Then
WordWasNotRunning = True
End If
Err.Clear ' Clear Err object in case error occurred.

'Check for Microsoft Word. If Microsoft Word is running,
'enter it into the Running Object table.
DetectWord

Set Pptr = GetObject(Fullpth)
 
I use this:

....
Set appWord = GetObject(, "Word.application") 'instance open already?

If Err = 0 Then
'optional ... will go ahead and open new instance
'MsgBox "Please close Word before running this merge operation."
'Exit Sub

ElseIf Err = 429 Then

Set appWord = GetObject("", "Word.application")
End If
....
 
Dave,
I'll give that a try. Many thanks...

DaveT said:
I use this:

...
Set appWord = GetObject(, "Word.application") 'instance open already?

If Err = 0 Then
'optional ... will go ahead and open new instance
'MsgBox "Please close Word before running this merge operation."
'Exit Sub

ElseIf Err = 429 Then

Set appWord = GetObject("", "Word.application")
End If
...


--
Dave Thompson
Allen, TX
US


Richard said:
I've created a documentation database for documenting Health Systems
interfaces in a 22 hospital organization. The nterface folks fill out a MS
Word document based on a MS Word tempate I created. From Access I have the
below code. The code generates a R$un time error, NOT deferred by ON ERROR
RESUME NEXT, "429" "ActiveX can't create Object". Anyone have any ideas on
this? I've tried everything I can think of. My code is right out of the help
files with needed adjustments... Any help would be appreciated :-)

Private Sub Command239_Click()
Dim Pptr As Object, cntr1 As Integer, cntr2 As Integer, Tptr As Object
Dim filpth As String, FileName As String, Fullpth As String, prop As Variant
Dim WordWasNotRunning As Boolean ' Flag for final release.


DoCmd.OpenForm "Word Import", acNormal, , , acFormEdit, acDialog
filpth = Forms![BldReportFrm].pthstring
FileName = Forms![BldReportFrm].FileName
Fullpth = filpth & "\" & FileName

On Error Resume Next ' Defer error handling.
Set Pptr = GetObject(, "Word.Application")
If Err.Number <> 0 Then
WordWasNotRunning = True
End If
Err.Clear ' Clear Err object in case error occurred.

'Check for Microsoft Word. If Microsoft Word is running,
'enter it into the Running Object table.
DetectWord

Set Pptr = GetObject(Fullpth)
 
Back
Top