R
Robert S.
This is being done with Office XP. I am trying to call a
word macro from Access using VBA. When I run it, I get an
error stating:
"438Object doesn't support this property or method.
Below is the code that I am using
==============================================
Private Sub cmdWordCreate_Click()
Dim appWord As Word.Application
Dim doc As Word.Document
Dim rst As ADODB.Recordset
Dim strSQL As String
Dim strLeadID As String
On Error Resume Next
Set appWord = GetObject(, "Word.application")
If Err = 429 Then
Set appWord = New Word.Application
Err = 0
End If
strLeadID = Me!LeadID
With appWord
Set doc = .Documents(DOC_NAME)
If Err = 0 Then
If MsgBox("Do you want to save the current
document " _
& "before updating the data?", vbYesNo) =
vbYes Then
.Dialogs(wdDialogFileSaveAs).Show
End If
doc.Close False
End If
On Error GoTo ErrorHandler
Set doc = .Documents.Open(DOC_PATH & DOC_NAME, , True)
Set rst = New ADODB.Recordset
With doc
doc.Run "Module1.addrow2"
'=============
' I get the error after the above statement is
run
End With
.Visible = True
.Activate
End With
doc.Close True
Set rst = Nothing
Set doc = Nothing
Set appWord = Nothing
Exit Sub
ErrorHandler:
MsgBox Err & Err.Description
End Sub
==================================
Thanks for the help
word macro from Access using VBA. When I run it, I get an
error stating:
"438Object doesn't support this property or method.
Below is the code that I am using
==============================================
Private Sub cmdWordCreate_Click()
Dim appWord As Word.Application
Dim doc As Word.Document
Dim rst As ADODB.Recordset
Dim strSQL As String
Dim strLeadID As String
On Error Resume Next
Set appWord = GetObject(, "Word.application")
If Err = 429 Then
Set appWord = New Word.Application
Err = 0
End If
strLeadID = Me!LeadID
With appWord
Set doc = .Documents(DOC_NAME)
If Err = 0 Then
If MsgBox("Do you want to save the current
document " _
& "before updating the data?", vbYesNo) =
vbYes Then
.Dialogs(wdDialogFileSaveAs).Show
End If
doc.Close False
End If
On Error GoTo ErrorHandler
Set doc = .Documents.Open(DOC_PATH & DOC_NAME, , True)
Set rst = New ADODB.Recordset
With doc
doc.Run "Module1.addrow2"
'=============
' I get the error after the above statement is
run
End With
.Visible = True
.Activate
End With
doc.Close True
Set rst = Nothing
Set doc = Nothing
Set appWord = Nothing
Exit Sub
ErrorHandler:
MsgBox Err & Err.Description
End Sub
==================================
Thanks for the help