General discussion


Access Question....

By j2per ·
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
'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
End With
Set doc = Nothing
Set appWord = Nothing
Exit Sub
MsgBox Err.Number & ": " & Err.Description
End Sub

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

try mail merge

by PurpleSkys In reply to Access Question....

under mailings maybe? we just did a bunch of that kinda thing at school (we had to create certificates for the School of Business for our local college), we just did a merge after creating the data for it.
edit: i'm curious why you;re using word instead of publisher to make a certificate though?

Related Discussions

Related Forums