Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Replace mergefields with form fields
Hi All,
I'm kind of new to Word mailmerge, macros and vba. I currently have a 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 form 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 are creating a vb application which should populate these fields instead of a data source. Any help would be appreciated. Thanks Jas |
#2
|
|||
|
|||
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 -- 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 "jassi_Hayre" wrote in message ... Hi All, I'm kind of new to Word mailmerge, macros and vba. I currently have a 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 form 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 are creating a vb application which should populate these fields instead of a data source. Any help would be appreciated. Thanks Jas -- jassi_Hayre |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Blank return for drop-down form fields | Microsoft Word Help | |||
How do I use a form then mailmerge without losing the form fields | Mailmerge | |||
How do I find & replace "text form fields"? | Microsoft Word Help | |||
Having multiple form fields automatically updated | Microsoft Word Help | |||
Email a protected document that contains Text Form Fields | New Users |