Word Merge From Access

G

Guest

Hi, I'm getting an error message "User-Defined Type Not Defined"

my code is as follows:

Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("C:\Sample DB Code\Word\NoticeFirst.doc",
"Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the newtheatreforms database.
objWord.MailMerge.OpenDataSource _
Name:="C:\_WORKING DATABASES\VideoLibrary.mdb",
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=0, _
Connection:="TABLE qNotice", _
SQLStatement:="SELECT * FROM [qNotice]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function


I knwo it's probably a very simple problem, but evidently my brain isn't
functioning today.

Thanks for any help.
 
J

John Nurick

Hi Kathy,

Does your project include a reference to Word?

If that's not the answer, tell us which statement raises the error.

Hi, I'm getting an error message "User-Defined Type Not Defined"

my code is as follows:

Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("C:\Sample DB Code\Word\NoticeFirst.doc",
"Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the newtheatreforms database.
objWord.MailMerge.OpenDataSource _
Name:="C:\_WORKING DATABASES\VideoLibrary.mdb",
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=0, _
Connection:="TABLE qNotice", _
SQLStatement:="SELECT * FROM [qNotice]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function


I knwo it's probably a very simple problem, but evidently my brain isn't
functioning today.

Thanks for any help.
 
G

Guest

Thanks John, References was the problem.

John Nurick said:
Hi Kathy,

Does your project include a reference to Word?

If that's not the answer, tell us which statement raises the error.

Hi, I'm getting an error message "User-Defined Type Not Defined"

my code is as follows:

Function MergeIt()
Dim objWord As Word.Document
Set objWord = GetObject("C:\Sample DB Code\Word\NoticeFirst.doc",
"Word.Document")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the newtheatreforms database.
objWord.MailMerge.OpenDataSource _
Name:="C:\_WORKING DATABASES\VideoLibrary.mdb",
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
WritePasswordDocument:="", _
WritePasswordTemplate:="", Revert:=False, Format:=0, _
Connection:="TABLE qNotice", _
SQLStatement:="SELECT * FROM [qNotice]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function


I knwo it's probably a very simple problem, but evidently my brain isn't
functioning today.

Thanks for any help.
 

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