Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / October 2003

Tip: Looking for answers? Try searching our database.

HOW TO Remove Invalid Merge Fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jason - 18 Oct 2003 06:01 GMT
I am using VB to automate Word 2002 and am trying to delete invalid merge
fields before I run a mail merge. I am enumerating the fields in the main
document but I cannot see a name property anywhere. What is the easiest way
to get the name of each merge field, or just to suppress the invalid merge
field message that occurs during the merge?

Thanks,

Jason
Doug Robbins - Word MVP - 19 Oct 2003 02:40 GMT
Hi Jason,

You can get the names of the mergefields in the mailmerge main document by
using the following:

Dim mf As Field, mfname As Range
Dim i As Integer, j As Integer

counter = 0
For Each mf In ActiveDocument.Fields
   If mf.Type = wdFieldMergeField Then
       Set mfname = mf.Code
       i = InStr(mfname, Chr(34))
       j = InStr(Mid(mfname, i + 1), Chr(34))
       mfname.End = mfname.Start + i + j - 1
       mfname.Start = mfname.Start + i
       MsgBox mfname
   End If
Next mf

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested.  Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
> I am using VB to automate Word 2002 and am trying to delete invalid merge
> fields before I run a mail merge. I am enumerating the fields in the main
[quoted text clipped - 5 lines]
>
> Jason
Jason - 29 Oct 2003 12:06 GMT
Perfect...thanks.

> Hi Jason,
>
[quoted text clipped - 32 lines]
> >
> > Jason
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.