Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am trying to open a predefined mail merge document from access us VBA and when the document opens it opens another instance of Access. I used Q159328 for the programming and found another article for this similar problem (Q199963) but nothing seems to help. Any assistance would be greatly appreciated.

Hi John
This is ripped out of a database I've just rebuilt. Its not pretty, but it works. There may be better ways, but this is the best I can do in 97. I hope its as self-explanatory as you need.
"AccessDataString$" contains the text I want to be merged, in fields seperated by a delimiting character which the destination Word template is expecting.
"MergeTemplate.doc" is set up to expect to be based on a datasource called "TextForMerge.doc".
You may want to bugger about to make the template read-only. You can do this with the "Open" statement or in the file properties. Or you can tell Word that its already saved it, so it won't ask you for it.
Cheers
Tom
Sub exportdata()
Dim AccessDataString$
Dim objword As New Word.Document
objword.Content.Text = AccessDataString$
objword.Application.Options.SavePropertiesPrompt = Falseobjword.SaveAs ("c:TextForMerge.doc")
Word.Documents.Open "c:MergeTemplate.dot"
ActiveDocument.MailMerge.Execute
ActiveDocument.Application.Visible = True
End Sub

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |