Reply
 
Thread Tools Display Modes
  #1   Report Post  
jassi_Hayre jassi_Hayre is offline
Junior Member
 
Posts: 1
Default 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   Report Post  
Doug Robbins
 
Posts: n/a
Default

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blank return for drop-down form fields Peter B. Microsoft Word Help 4 January 26th 07 05:01 PM
How do I use a form then mailmerge without losing the form fields Someone who's stuck Mailmerge 1 June 23rd 05 10:01 AM
How do I find & replace "text form fields"? OneClothEar Microsoft Word Help 1 April 13th 05 10:15 PM
Having multiple form fields automatically updated jrwaguespack Microsoft Word Help 3 March 25th 05 07:43 AM
Email a protected document that contains Text Form Fields Dowza New Users 1 January 8th 05 10:31 AM


All times are GMT +1. The time now is 07:17 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"