Access Question.... - TechRepublic
General discussion
April 20, 2010 at 01:33 PM
j2per

Access Question….

by j2per . Updated 16 years, 1 month ago

Below you will find the code I used to try to print a “certificate” from word… I click the button and nothing happens… if the code is right then I may have it linked ot the button wrong… Oh how I miss the old access LOL

Private Sub cmdPrint_Click()
‘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:\Users\owner\Desktop\Access_Forms\Cert.docx”, , True)
With doc
.FormFields(“fname”).Result = Me!FName
.FormFields(“lname”).Result = Me!LName
.FormFields(“sadd”).Result = Me!Street
.FormFields(“city”).Result = Me!City
.FormFields(“state”).Result = Me!State
.FormFields(“zip”).Result = Me!Zip
.FormFields(“certnum”).Result = Me!Cert_number
.Visible = True
.Activate
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
errHandler:
MsgBox Err.Number & “: ” & Err.Description
End Sub

This discussion is locked

All Comments