User defined type not defined error in mail merge from Access 2003

  • Thread starter Caroline Higson
  • Start date
C

Caroline Higson

Hello lovely kind people!

I want to open a letter in Word 03 from Access 03 with my merge fields
in, merge, and print. It worked once, but now it's not? It highlights
the first line and comes up with a complie error: user defined type not
defined. Does anyone know what's wrong with my code (which I "borrowed"
off here!)?


Dim objWord As Word.Document
Set objWord = GetObject("C:\ICT2\welcome letter.doc",
"Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Rat Rescue database.
objWord.MailMerge.OpenDataSource _
Name:="C:\ICT2\db7.mdb", _
LinkToSource:=True, _
Connection:="TABLE Table1", _
SQLStatement:="SELECT * FROM [Table1]"

objWord.MailMerge.Destination = wdSendToNewDocument
objWord.MailMerge.Execute
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
End Function

Thanks in advance!

Caroline
 
B

Barry Gilbert

On what line does it fail? My guess would be on the first line. If so, you
might have a broken reference. Go to Tools, References in the VBA Editor
window and make sure that Microsoft Word 11.0 Object Library is checked.

Barry
 

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