Discussion:
How to get the values for Comparison,CompareTo and TrueAutoText
(too old to reply)
Sunil Sudhakaran
2008-10-14 16:31:03 UTC
Permalink
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 ***@gmai.com"}

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.
Doug Robbins - Word MVP
2008-10-14 19:34:36 UTC
Permalink
Sorry, I do not understand what you are trying to do.

{ if {MERGEFIELD Version} = "CustomerA" "contact ***@gmai.com"}

should return "contact ***@gmai.com" 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
Post by Sunil Sudhakaran
I have a Document that is having many Field codes.
I would like to extract the following information from the if field.
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.
Peter Jamieson
2008-10-14 23:35:23 UTC
Permalink
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.
--
Peter Jamieson
http://tips.pjmsn.me.uk
Post by Sunil Sudhakaran
I have a Document that is having many Field codes.
I would like to extract the following information from the if field.
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.
Loading...