Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automation from Access 2003 to Word 11.0

Status
Not open for further replies.

Magpies007

Programmer
Jul 14, 2008
1
Hi all I am new to this forum please bear with me. I am trying to write some code for a command button in my access application to merge an existing letter with a a query . The code is this
Function MergeIt()
Dim objWord As Word.Application
Set objWord = GetObject("C:\Documents and Settings\Rob\My Documents\Whitsundays\Operational Works\Template - Letter On maintenance Defects.doc", "Word.Application")
' Make Word visible.
objWord.Application.Visible = True
' Set the mail merge data source as the Operational Work database.
objWord.MailMerge.OpenDataSource _
Name = "C:\Documents and Settings\Rob\My Documents " & _
"Whitsundays\Operational Works\Ops Work Database\Operational Works.mdb", _
LinkToSource:=True, _
Connection:="QUERY Merge details Defects", _
SQLStatement:="SELECT * FROM [merge details defects]"
' Execute the mail merge.
objWord.MailMerge.Execute
End Function

I get a compile error "Method or Data member not found", on the line "objWord.MailMerge.OpenDataSource". with .MailMerge highlighted. I am at a loss as to why. Please can anyone help.Thank in advance:)
 
Though automation is slick, another way to do mail merges is within Access. Create a report using textboxes and change a detail property.
Click on the Detail Bar. On the property sheet, make Force New Page show After Section. Using textboxes, format your letter, eg. the control source for the salutation textbox would look like: ="Dear " & [Fname] & " :"
Then have a big textbox for the main message. Etc.
So each record of your query would produce it's own letter due to the Force New Page.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top