Blank lines in mailmerge not removed if using VBA

A

Adrian

Using Word 2000 (and Access 2000)

I have a Word mailmerge document that I am running from an Access
application. I use the following code:

Set myWDApp = CreateObject("Word.Application")
myWDApp.Application.Visible = True
myWDApp.Documents.Open (strDocPath)
Set myDoc = myWDApp.ActiveDocument
With myDoc.MailMerge
.MainDocumentType = wdFormLetters
.OpenDataSource Name:=strCSV
.Destination = wdSendToNewDocument
.Execute True
End With

If I stop the code after 'Set myDoc = myWDApp.ActiveDocument' and manually
run the mailmerge blank address lines are removed. If I just run the above
code the blank lines are not removed.

Is this a known problem, or am I doing something wrong here?

Thanks for any help.

Adrian.
 
C

Cindy M -WordMVP-

Hi Adrian,
If I stop the code after 'Set myDoc = myWDApp.ActiveDocument' and manually
run the mailmerge blank address lines are removed. If I just run the above
code the blank lines are not removed.
If you add this, does the behavior change

(With mydoc.MailMerge)
.SuppressBlankLines = True

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
A

Adrian

Cindy,

Thanks for your help. It did resolve the problem.

It seems that the line: '.MainDocumentType = wdFormLetters' caused the blank
lines not to be suppressed as if I removed this there was no problem.

I am not sure what this line actually does (I did not write the code), but
on the basis that it was required I added suppressblanklines after it and it
now all works fine.

Thanks again for your help.

Adrian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top