0
votes

I am searching for the correct syntax for my macro to find an IF Conditional statement field code.

I need to search for {IF{DOCVARIABLE"CODE"} = "YES" "A" "B"} to remove this and replace with "B" (the false statement).

When searching for a word field like {DOCVARIABLE "CODE"} alone, I write as: Text1 = "CODE" but when there is an IF & Text & Yes & TRUE, FALSE like above, how do I write?

1
looks like you cross-posted in social.msdn.microsoft.com/Forums/en-US/worddev/thread/…user1379931

1 Answers

0
votes

Consolidated comment (OP crossposted elsewhere):

For that specific sequence, you can search for

^19IF^19DOCVARIABLE"CODE"

Word will select the entire IF field (so you will then need to parse the entire IF field anyway), but it should not select e.g.

{IF{DOCVARIABLE"BOX"}

If there is some variation (e.g. additional whitespace in the string) you may be able to use something like

^19^wIF^w^19^wDOCVARIABLE^w"CODE"