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.

Re: Blank lines in mailmerge not removed if using VBA by Cindy

Cindy
Sun Jul 04 04:42:04 CDT 2004

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 :-)


Re: Blank lines in mailmerge not removed if using VBA by Adrian

Adrian
Wed Jul 07 06:39:12 CDT 2004

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

"Cindy M -WordMVP-" <C.Meister-C@hispeed.ch> wrote in message
news:VA.00009cac.005c663c@speedy...
> 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 :-)
>