Merging a query with MS Word using VB

G

Guest

I am getting the error message that my sub or function is not defined:

Private Sub Command8_Click()
Dim objWord As Word.Document
Select Case Me.lstNotices
Case 1
Set objWord = GetObject _
("Z:\Word Documents\Jantize America\Access Merge Documents\45+
Day Clients", _
"Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the my DB.
objWord.MailMerge.OpenDataSource _
Name:="Z:\Access Databases" & _
"Jantize DBs\Jennifer.mdb", _
LinkToSource:=True, _
Connection:="TABLE CUST1 INNER JOIN INVOICE ON CUST1.CONUM =
INVOICE.CONUM ", _
SQLStatement:="SELECT * FROM [CUST1] And [INVOICE]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Select
End Sub

It's for a past due notice and I want to have the Merge statements embedded
in a case statement so the user can select which criteria (which query) to
base the notices from (haven't gotten to the other cases yet). My SQL for the
queries are pretty lenghty so I tried to simplify(?) but I hadn't even gotten
to troubleshooting that part. Any suggestions would be helpful.

I used the following page as a reference for the Procedure:
http://support.microsoft.com/?kbid=209976

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top