A Microsoft Word forum. Microsoft Office Word Forum - WordBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Microsoft Office Word Forum - WordBanter forum » Microsoft Word Newsgroups » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

mail merge field names



 
 
Thread Tools Display Modes
  #1  
Old March 8th 05, 06:17 PM
Edwin Patrick
external usenet poster
 
Posts: n/a
Default mail merge field names

How can I Loop through all the mail mertge fields in a document
and display the field Name?
Ads
  #2  
Old March 8th 05, 11:49 PM
Doug Robbins
external usenet poster
 
Posts: n/a
Default

Dim af As Field
For Each af In ActiveDocument.Fields
If af.Type = wdFieldMergeField Then
MsgBox af.Code
End If
Next af

Use the Mid() function to get rid of the MERGEFIELD if you don't want to
display it.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
"Edwin Patrick" wrote in message
...
How can I Loop through all the mail mertge fields in a document
and display the field Name?



  #3  
Old March 9th 05, 04:25 PM
Edwin Patrick
external usenet poster
 
Posts: n/a
Default

Thanks for your help.
But I do not get the field name I get a error message at the line "msgbox
af.code" since code is a field type of "Range".
I am still in the same problem now.
All I need to do is to loop through all the merge fields in the
word document and create an array and replace the mergefields with the
values I get from the database.
Any suggestion will be of great help.

"Doug Robbins" wrote:

Dim af As Field
For Each af In ActiveDocument.Fields
If af.Type = wdFieldMergeField Then
MsgBox af.Code
End If
Next af

Use the Mid() function to get rid of the MERGEFIELD if you don't want to
display it.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
"Edwin Patrick" wrote in message
...
How can I Loop through all the mail mertge fields in a document
and display the field Name?




  #4  
Old March 9th 05, 05:33 PM
Peter Jamieson
external usenet poster
 
Posts: n/a
Default

Try

af.Code.Text

But you will have to strip off the MERGEFIELD, white space, and any quotes
to get the name of the field, and it may not match the one in the data
source if, for example, the data source has field names longer than around
32 characters. And so on...

Peter Jamieson

"Edwin Patrick" wrote in message
...
Thanks for your help.
But I do not get the field name I get a error message at the line "msgbox
af.code" since code is a field type of "Range".
I am still in the same problem now.
All I need to do is to loop through all the merge fields in the
word document and create an array and replace the mergefields with the
values I get from the database.
Any suggestion will be of great help.

"Doug Robbins" wrote:

Dim af As Field
For Each af In ActiveDocument.Fields
If af.Type = wdFieldMergeField Then
MsgBox af.Code
End If
Next af

Use the Mid() function to get rid of the MERGEFIELD if you don't want to
display it.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a
paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
"Edwin Patrick" wrote in message
...
How can I Loop through all the mail mertge fields in a document
and display the field Name?






  #5  
Old March 9th 05, 10:57 PM
Edwin Patrick
external usenet poster
 
Posts: n/a
Default

Thanks a lot guys.
It worked.
many thanks.

"Peter Jamieson" wrote:

Try

af.Code.Text

But you will have to strip off the MERGEFIELD, white space, and any quotes
to get the name of the field, and it may not match the one in the data
source if, for example, the data source has field names longer than around
32 characters. And so on...

Peter Jamieson

"Edwin Patrick" wrote in message
...
Thanks for your help.
But I do not get the field name I get a error message at the line "msgbox
af.code" since code is a field type of "Range".
I am still in the same problem now.
All I need to do is to loop through all the merge fields in the
word document and create an array and replace the mergefields with the
values I get from the database.
Any suggestion will be of great help.

"Doug Robbins" wrote:

Dim af As Field
For Each af In ActiveDocument.Fields
If af.Type = wdFieldMergeField Then
MsgBox af.Code
End If
Next af

Use the Mid() function to get rid of the MERGEFIELD if you don't want to
display it.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a
paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
"Edwin Patrick" wrote in message
...
How can I Loop through all the mail mertge fields in a document
and display the field Name?






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
mail merge with attachments AS Mailmerge 5 April 9th 05 09:49 AM
How do I mail merge to have different names on the main docume TonyM Mailmerge 1 January 25th 05 11:06 PM
Switch an image dynamically based on mail merge field - possible? Chris Hlusak Mailmerge 1 January 24th 05 11:11 PM
Mail Merge Field Stripping M. Johnson Mailmerge 3 January 12th 05 04:34 PM
How do I get a field to self adjust in a mail merge? DD Holt Mailmerge 1 December 29th 04 06:30 PM


All times are GMT +1. The time now is 10:50 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 2004-2014 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.