R
RonKProSpect
I am trying to add a database field to a word document using the code below.
The Work doc contains merge field....<<InspAddress>>. When I run the code
from access, it opens the Word document by I get the error message "Run-time
'5': Invalid procedure call or arument at line>>
prps.Item("InspAddress").Value = strInspAddress. I am running Access 2003
and Word 2002. Thanks
Private Sub Command76_Click()
Dim appWord As Word.Application
Dim docs As Word.Documents
Dim strLetter As String
Dim strTemplateDir As String
Dim prps As Object
Dim strInspAddress As String
Set appWord = GetObject(, "Word.Application")
strTemplateDir = "C:\Documents and Settings\All Users\Documents\Pro-Spect
Professional Home Inspections\Administration\Legal\"
Debug.Print "Office template directory: " & strTemplatDir
strLetter = strTemplateDir & "Home Inspection Agreement Template.doc"
Debug.Print strLetter
Set docs = appWord.Documents
docs.Add strLetter
strInspAddress = Me.InspAddress
Set prps = appWord.ActiveDocument.CustomDocumentProperties
prps.Item("InspAddress").Value = strInspAddress
With appWord
.Selection.WholeStory
.Selection.Fields.Update
.Visible = True
.Activate
End With
The Work doc contains merge field....<<InspAddress>>. When I run the code
from access, it opens the Word document by I get the error message "Run-time
'5': Invalid procedure call or arument at line>>
prps.Item("InspAddress").Value = strInspAddress. I am running Access 2003
and Word 2002. Thanks
Private Sub Command76_Click()
Dim appWord As Word.Application
Dim docs As Word.Documents
Dim strLetter As String
Dim strTemplateDir As String
Dim prps As Object
Dim strInspAddress As String
Set appWord = GetObject(, "Word.Application")
strTemplateDir = "C:\Documents and Settings\All Users\Documents\Pro-Spect
Professional Home Inspections\Administration\Legal\"
Debug.Print "Office template directory: " & strTemplatDir
strLetter = strTemplateDir & "Home Inspection Agreement Template.doc"
Debug.Print strLetter
Set docs = appWord.Documents
docs.Add strLetter
strInspAddress = Me.InspAddress
Set prps = appWord.ActiveDocument.CustomDocumentProperties
prps.Item("InspAddress").Value = strInspAddress
With appWord
.Selection.WholeStory
.Selection.Fields.Update
.Visible = True
.Activate
End With