Hi,
I've found a tutorial that shows you how to fill in Word documents with values from Access
I am using Office 2007 and it doesn't seem to be working. I can see that WINWORD.exe is open in my Task Manager but the actual word document is not launching.
Does anybody know how to modify the above code to make it work with Office 2007.
Thanks,
Marat
I've found a tutorial that shows you how to fill in Word documents with values from Access
Code:
'Print customer slip for current customer.
Dim appWord As Word.Application
Dim doc As Word.Document
'Avoid error 429, when Word isn't open.
On Error Resume Next
Err.Clear
'Set appWord object variable to running instance of Word.
Set appWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
'If Word isn't open, create a new instance of Word.
Set appWord = New Word.Application
End If
Set doc = appWord.Documents.Open("C:\BLANK INSTRUCTION_TEMPLATE.docx", , True)
With doc
.FormFields("fldCustomerID").Result = Me!CustomerID
.FormFields("fldCompanyName").Result = Me!CompanyName
.FormFields("fldContactName").Result = Me!ContactName
.FormFields("fldContactTitle").Result = Me!ContactTitle
.FormFields("fldAddress").Result = Me!Address
.FormFields("fldCity").Result = Me!City
.FormFields("fldRegion").Result = Me!Region
.FormFields("fldPostalCode").Result = Me!PostalCode
.FormFields("fldCountry").Result = Me!Country
.FormFields("fldPhone").Result = Me!Phone
.FormFields("fldFax").Result = Me!Fax
.Visible = True
.Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox Err.Number & ": " & Err.Description
Does anybody know how to modify the above code to make it work with Office 2007.
Thanks,
Marat
Comment