How to parse Word Template file having Merge Fields in text objects

B

Bravo

Hi,

I have a word template file having mail merge fields in
it, but when I am trying to open the file from VB and
reading the fields document.mailmerge.fields.count, it is
not showing me all field count.

The template is having merge fields in textbox objects
and somehow I am not getting those text objects too
programmatically.

My purpose is to parse the word template file and read
all information about the merge fields and post
appropriate values in it programmatically.

Please help. if somebody has code, please send me..

thanks
Bravo
 
P

Peter Jamieson

You will need at least

Dim oDoc as Word.Document
Dim r as Word.Range
Dim f as Word.Field
' set oDoc somewhere before here
With oDoc
For Each r in .StoryRanges
For Each f in r.Fields
' examine f.Type and take it from there.
Next
Next
End With
 

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