How to suppress the blank lines while mering fields in Word docume

C

CoolVBA

I'm using a Word OCX control to display document, and need toggle the
document display between merged and unmerged status, the VBA code seems as
below:

.mailmerge.opendatasourece(...)
.mailmerge.suppressblanklines = true

if ...
.mailmerge.viewmergefieldcodes = true
else
.mailmerge.viewmergefieldcodes = false
end if

After the above scripts run, I found the blank lines were never been
suppressed while empty fields existed, I know the .Execute() method can
suppress the blank lines, but it will permanently convert the doucment, it's
not what I wanted.
 
D

Doug Robbins - Word MVP

You would need to use an If...then...Else construction in the mail merge
main document to test for data in the fields to achieve what you are after.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
C

CoolVBA

Thanks much!

My case is that a text file is used as the data source which is exported by
program, and users can insert any merge fileds into a Word document. So, it
seems too diffcuilt to manage all the Next Merge Fields while the If
....then...Else construction used...
 
C

CoolVBA

Thanks much!

My case is that a text file is used as the data source which is exported by
program, and users can insert any merge fileds into a Word document. so, it
seems diffcuilt to manage all the Next fields while if...then...else
construction used...
 

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