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 / August 2005

Tip: Looking for answers? Try searching our database.

Replace mergefields with form fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jassi_Hayre - 16 Aug 2005 17:37 GMT
Hi All,

I'm kind of new to Word mailmerge, macros and vba. I currently have
problem where we have nearly 200 word templates that use mail merge
The data source is an Oracle8 database which is going to be scrapped.

I'd like to replace the mergefields on these templates with either for
fields or bookmarks programmaticaly.

Here's what i'd like to do in detail -

Search for a mergefield
Strip its name
Add a form field / bookmark where the mergefield is
Give this form field / bookmark the stripped out name.
Delete the mergefield

I'd like to use form fields instead of the merge fields because we ar
creating a vb application which should populate these fields instead o
a data source.

Any help would be appreciated.
Thanks
Ja

--
jassi_Hayre
Doug Robbins - 16 Aug 2005 22:49 GMT
Given that there are problems with assigning names to formfields that are
inserted with VBA, I would suggest that you use docvariable fields instead
and have you vb application assign values to the variables.

The following code will replace the mergefields with docvariable fields of
the same name

Dim af As Field, fname As String, frange As Range
For Each af In ActiveDocument.Fields
If af.Type = wdFieldMergeField Then
   Set frange = af.Code
   fname = Trim(Mid(frange, 13))
   frange = "Docvariable " & fname
End If
Next af
ActiveDocument.Fields.Update

Signature

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

>
> Hi All,
[quoted text clipped - 21 lines]
> Thanks
> Jas
 
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.