How to get the values for Comparison,CompareTo and TrueAutoText

S

Sunil Sudhakaran

I have a Document that is having many Field codes.

I would like to extract the following information from the if field.

{ if {MERGEFIELD Version} = "CustomerA" "contact (e-mail address removed)"}

I tried using MailMergeField.Next.Code got the Condition, not able to get
other values

Dim doc As Document
Dim fld As MailMergeField
Set doc = ActiveDocument
For Each fld In doc.MailMerge.Fields
........
If fld.Type = wdFieldIf Then
..........
MsgBox fld.Next.Code
End if

How to get the values for Comparison,CompareTo and TrueAutoText

Regards
Sunil S.
 
D

Doug Robbins - Word MVP

Sorry, I do not understand what you are trying to do.

{ if {MERGEFIELD Version} = "CustomerA" "contact (e-mail address removed)"}

should return "contact (e-mail address removed)" IF the Version field contains
"CustomerA" AND you used Ctrl+F9 to insert the field delimiters { }

--
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
 
P

Peter Jamieson

I don't think Word provides any any properties or functions that will
extract these parts of the IF field for you, and I suspect it will be quite
complicated to do it yourself. I certainly do not have code to do it.

For one thing, I doubt that

MsgBox fld.Next.Code

is giving you the full Condition (i.e. '{ MERGEFIELD Version } = "Customer
A"' ), just the next MERGEFIELD. And the problem is that the first part of
the condition is not necessarily even a field. Or it might be a nested
field. The result areas can also contain almost anything - text, fields,
including further IF statements, inline graphics etc. They may or may not be
wrapped in double quotes, and so on.
 

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