I’ve created a button that opens a Word Mail Merge document. Except now it isn’t working and I don’t know what I did wrong. I keep getting the error “User-defined type not defined”. Does anyone have any idea? The following is the code that I have behind the button.
Private Sub DoneSelectingbtn_Click()
On Error GoTo Err_DoneSelectingbtn_Click
DoCmd.GoToRecord , , acLast
MergeIt
Exit_DoneSelectingbtn_Click:
Exit Sub
Err_DoneSelectingbtn_Click:
MsgBox Err.Description
Resume Exit_DoneSelectingbtn_Click
End Sub
Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject(“G:StudentLabels5163.doc”, “Word.Document”)
‘ Make Word visible.
objWord.Application.Visible = True
‘ Set the mail merge data source as the Northwind database.
objWord.MailMerge.OpenDataSource _
Name:=”G:WorkingCopy.mdb”, _
LinkToSource:=True, _
Connection:=”QUERY Labels Query”
‘ Execute the mail merge.
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
End Function