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

Problem launching "directory" type mail merge documents from Access

P: n/a
I have set up a Word mail merge document of the type Directory which
allows me to display all of the records on a single page rather than
putting each record on a separate page. It uses a temporary table in
MS Access as its datasource (loaded via a Make Table query). If I
create the temporary table and then open the mail merge document from
within MS Word and click "Merge to New Document", the information from
the temporary table is displayed in the table that I have set up. The
table looks normal with all rows on the same page.

If I use VBA to launch Word and open the same document, the data
appears but there is a section break between each row of the table. If
I want the table all together on the page, I have to manually delete
all of the section breaks. Can anybody tell me why the section breaks
are being inserted when they are clearly not in the original document?

The code that I am using is pretty standard. I am passing strTableName
as a parameter to the procedure.

Dim wrkDefault As Workspace
Dim WordDoc As Object
Dim WordApp As Object
Dim db As Database

Set db = CurrentDb

Set wrkDefault = DBEngine.Workspaces(0)

' open up word with the Mail Merge document, using the path that we
found
' with the File Open dialogue box above.
Set WordApp = CreateObject("word.application")
Set WordDoc = WordApp.Documents.Open(strInputFileName)
WordDoc.Application.Visible = True
WordDoc.MailMerge.OpenDataSource Name:=db.Name, LinkToSource:=True,
Connection:="TABLE " & strTableName, SQLStatement:="SELECT * FROM [" &
strTableName & "]"
Set db = Nothing

Thanks for any help you may have,
Sheila

May 4 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.