Macro to extract data from merge field on Word Document

D

Doug

I have a template containing merge fields on the MS Word
Document. I am trying to get the value of the specific
field. I can get a count of the merge fields, I can
actually get a value from a field if I use a specific
element number. However, I need to use the field name.

THIS WORKS:
intTempCount = ThisDocument.Fields.Count
THIS WORKS:
ThisDocument.Fields.Item(1).Result

If I put a specific field name in the statement, I get an
error. Run-time error 13 Type Mismatch
THIS DOESN'T WORK:
ThisDocument.Fields.Item("FaxNumber").Result

I REALLY need to get the value for a specific field. Any
help would be great. Thanks!
 
H

Helmut Weber

Hi Doug,
couldn't get any hint on a straightforward solution.
You might create an array of fieldnames or string-items,
get the index for the fieldname and call the field by the
index. Probably done that anway by now.
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT 4.0
 
C

Cindy Meister -WordMVP-

Hi Doug,
I have a template containing merge fields on the MS Word
Document. I am trying to get the value of the specific
field. I can get a count of the merge fields, I can
actually get a value from a field if I use a specific
element number. However, I need to use the field name.
Please note that what will be returned depends on the mail
merge record being displayed...

ActiveDocument.MailMerge.DataSource.DataFields("FieldName")
Value

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jan 24 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top