By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

Trouble with Access97 and Word

P: n/a
Hi All,
I'm trying to get this(see below) to work but have not been successful
so far, what I'm trying to get done is;

open a word document which is already setup as a mailmerge document
merge the one record from the table to the document
save the fillin documment with a diff name
close the mailmerge document
close word

can someone fix my vba code

Dim strGetDoc As String, strOutNme As String
strGetDoc =
"\\Homa\CommonDbs\EventSpend\Documentation\Meeting Authorization.doc"
strOutNme =
"\\Homa\CommonDbs\EventSpend\Documentation\Authori ze.doc"

Dim objWord As Word.Document
Set objWord = GetObject(strGetDoc, "Word.Document")
'Make Word visible.
objWord.Application.Visible = True
'Set the mail merge data source as the database containing the mail
merge data.
objWord.MailMerge.OpenDataSource _
Name:="\\Homa\CommonDbs\EventSpend\Apps\EventSpend XP.mdb", _
LinkToSource:=False, _
Connection:="Table tblAuthorizationData",
SQLStatement:="Select * from [tblAuthorizationData]"
'Execute the mail merge.
objWord.MailMerge.Destination = wdSendToNewDocument
objWord.SaveAs (strOutNme)
objWord.MailMerge.Execute
'close the Word application
objWord.Application.Quit
Set objWord = Nothing

thanks for any and all help
bobh.

Apr 19 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.