GaryCanuck
Technical User
Hi All,
I'm currently using both Word and Access 2007. I want to insert a table of selected values into a mailmerge letter. If I enter the fields in and hit run then I get an individual letter for each record. However if the table is a separate document then it merges continuously as desired. So what I am aiming to do is merge the table, merge the letter and then copy and paste the table into the letter from access vba. When I run the code (from button) I get an extra version of word running and a message saying the remote server is unavailable. I'm lead to believe this is due to improperly sourcing, identifying variables, etc. Any ideas where it's going astray? Here is my most recent attempt:
Any help is always appreciated, thanks in advance,
Tyler
I'm currently using both Word and Access 2007. I want to insert a table of selected values into a mailmerge letter. If I enter the fields in and hit run then I get an individual letter for each record. However if the table is a separate document then it merges continuously as desired. So what I am aiming to do is merge the table, merge the letter and then copy and paste the table into the letter from access vba. When I run the code (from button) I get an extra version of word running and a message saying the remote server is unavailable. I'm lead to believe this is due to improperly sourcing, identifying variables, etc. Any ideas where it's going astray? Here is my most recent attempt:
Code:
DoCmd.SetWarnings False
DoCmd.OpenQuery "Notice of Public Auction"
DoCmd.SetWarnings True
Dim db As Database
Set db = OpenDatabase("\\Taxerver\taxervice\Access\TaxSale_be.mdb")
Dim objWord As Word.Document
Set objWord = GetObject("\\Taxerver\taxervice\Templates\Public Auction Table.docx", "Word.Document")
objWord.Application.Visible = False
objWord.MailMerge.Execute
Selection.WholeStory
Selection.Copy
objWord.Close False
Dim oWord As Word.Document
Set oWord = GetObject("\\Taxerver\taxervice\Templates\Notice of Public Auction.docx", "Word.Document")
oWord.Application.Visible = True
oWord.MailMerge.Execute
oWord.Close False
Dim pWord As Word.Document
Set pWord = Word.ActiveDocument
pWord.Application.Visible = True
pWord.ActiveDocument.Bookmarks("Table2").Select
Selection.Paste
Any help is always appreciated, thanks in advance,
Tyler