Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

Word Nested Field Edit

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Chipping - 10 Nov 2005 12:55 GMT
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
Edward Thrashcort - 10 Nov 2005 14:39 GMT
Could you simply show field codes then use Find/Replace
to change "}={" to "} = {"

Eddie
David Chipping - 10 Nov 2005 15:08 GMT
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 :)
Tony Jollans - 10 Nov 2005 20:16 GMT
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 :)
Doug Robbins - Word MVP - 10 Nov 2005 20:46 GMT
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" }
Signature

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 :)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.