Word Nested Field Edit

D

David Chipping

Hi,

I'm not very experienced in VBA or Word, but I have a problem that I am
unable to solve with nested fields in Word.

For whatever reason (old version of word, client entry incorrectly) we
have a large set of files with IF fields containing nested MERGEFIELDS
that are used for comparison that have a syntax error and Word XP/2003
doesn't accept.

The problem comes from there being no spaces around the comparator,
like:

IF {MERGEFIELD xxx}={MERGEFIELD yyy} ... etc

Applying spaces around the equals gives fixes this; however, I am
unable to do this via VBA, as any addition to the code.text attribute
of the field object results in the nested fields being incorrectly
parsed and included as text elements of the IF field itself.

My question is therefore: how can I edit the code of a field that
contains nested fields and have the nested fields maintained via VBA!

Thanks,

-David
 
E

Edward Thrashcort

Could you simply show field codes then use Find/Replace
to change "}={" to "} = {"

Eddie
 
D

David Chipping

Nope,

Unfortunatly, because the mergefield is a nested field, word doesn't
allow you to simply do that. In the code I get:

IF  MERGEFIELD XXX  =  MERGEFIELD yyy  "lll" "kkk"

{'s are literally used within the top level field as part of the fields
contruct and the mergefields are lost as the .code.text field is not
parsed to incoperate nested fields ... which is my problem :)
 
T

Tony Jollans

With field codes displayed you could search for = and replace with (space,
=, space). It wouldn't do any harm to have too many spaces.

If need be you could then hide field codes and replace all (space, =, space)
with = to undo what you changed outside field codes

--
Enjoy,
Tony


Nope,

Unfortunatly, because the mergefield is a nested field, word doesn't
allow you to simply do that. In the code I get:

IF  MERGEFIELD XXX  =  MERGEFIELD yyy  "lll" "kkk"

{'s are literally used within the top level field as part of the fields
contruct and the mergefields are lost as the .code.text field is not
parsed to incoperate nested fields ... which is my problem :)
 
D

Doug Robbins - Word MVP

If you press Alt+F9 you will get

{ IF { MERGEFIELD XXX }={ MERGEFIELD yyy } "lll" "kkk" }

and when you have the field codes displayed like that, you CAN use Edit
Replace to replace the = with <space>=<space> where <space> represents the
use of the space bar so that the above field code construction will be
transformed to:

{ IF { MERGEFIELD XXX } = { MERGEFIELD yyy } "lll" "kkk" }
--
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

Nope,

Unfortunatly, because the mergefield is a nested field, word doesn't
allow you to simply do that. In the code I get:

IF  MERGEFIELD XXX  =  MERGEFIELD yyy  "lll" "kkk"

{'s are literally used within the top level field as part of the fields
contruct and the mergefields are lost as the .code.text field is not
parsed to incoperate nested fields ... which is my problem :)
 

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