Field Code 'IF Statements'

S

Scoprio540

Im working on a document that requires an IF statement in a field cod
in the footer.
This field code will detect if a bookmarked value exists and use it o
use the {SECTIONPAGES} tag (if it doesn't exist).
The field code is as follows -

{ if { PAGEREF { styleref "Section Heading" \r\t }SubSectionPage }
"Error! Bookmark not defined." {SECTIONPAGES} {PAGEREF { stylere
"Section Heading" \r\t }SubSectionPage} }

which then should equate to the following

{ if { PAGEREF HSubSectionPage } = "Error! Bookmark not defined.
{SECTIONPAGES} {PAGEREF HSubSectionPage} }

(HSubSectionPage is the bookmarked value)

However, my problem is that it always returns "Error! Bookmark no
defined." and therefore doest not evaluate it properly.

I think I have narrowed it down to the fact that it does not evaluat
the 'IF' statement in the correct order.

Please Help.

Thanks in advance
scorpio54
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

If I use

{ IF { = PageRef "test" } + 0 + "!Syntax Error, !" "No Bookmark"
"Bookmark" }

If returns No Bookmark if the bookmark does not exist and Bookmark, if it
does.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
S

Scoprio540

Just tried your suggestion but realised that doesn't work (under W97)
Your code produces a syntax error due to the " = " bit in the firs
embedded field code. Your IF statement checks for this syntax error an
returns the "No bookmark".

The way around this would be something like:

{if { pageref Test } = "Error! Bookmark not defined." "No Bookmark
"Bookmark Exists"}

I guess I did not explain myself fully. I have Sections A through to
in a document. In the footer of each section it needs to check if a su
section exists. If it does then use a bookmarked value in that su
section otherwise use a number in the current section.

All bookmarked values are in the syntax 'SectionA', 'SectionB
(according to which section they are in).

Therefore I need to get the current section Letter then look for
bookmark eg
if bookmarkvalue ('Section'+GetSectionLetter) = "" then "" else ""
but as previously stated it wont work.

Thanks in advance
Scorpio54
 

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