Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using fields codes , if statements and formulas in Word 2010 1

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
0
0
GB
Hi,

Does anyone know of any place I can find out about inserting field codes correctly?

I can't find anything on the web to help with using field codes, setting bookmark content using if statements or assiging dynamic data from mergefields?

I've been going round in circles for days but nothing I try works?

all i want is to use a simple If statement to set the content of a bookmark when the first record is merged?

I have this
Code:
{ if {mergeseq} = 1 {set Sig { mergefield "sSig" } } }

Where 'Sig' is the bookmark and 'sSig' is a mergefield, but the bookmark content doesn't change?

Why?

Thanks,
1DMF

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 

Word fields do not really offer conditional programming capacity; it only has imperative statements.

You cannot directly code:

IF something THEN DO something.

You need to turn the whole thing on its head and code:

[tt] Set something = something else[/tt]

where 'something else' can be of the form:

[tt] IF A is true
some value
ELSE
some other value
ENDIF[/tt]

So, in your case, you want to code something like:

[tt] { SET Sig { IF { MergeSeq } = 1 { MERGEFIELD sSig } } }[/tt]

You are always setting something; there is no default 'do nothing' option, so if you want to maintain a previous value, you need to amend it to something like:

[tt] { SET Sig { IF { MergeSeq } = 1 { MERGEFIELD sSig } { Sig } } }[/tt]


(untested!)


Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
I actually solved the issue : thread68-1660666

But this thread was more about being pointed to some learning material about field codes and their use rather than solving the actual problem.

But I still appreciate your input.

1DMF.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Word fields are an art, and can cause you to lose your sanity!

The best resources available are documents by Tek-Tips member, and Microsoft Word MVP, macropod. They are available on Graham Mayor's web site, here:

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top