#1
|
|||
|
|||
Error handling in formula - suppress 'Syntax Error'
I had to create a field which uses PageRef to a bookmark in it's calculation formula. Everything works the way I need it to, but in the off chance that the bookmark is deleted or renamed by the end user, I'd like the calculation to use 0 in the formula instead of showing a Syntax Error. How do I check in a formula if a bookmark exists, or if there is an error? |
#2
|
||||
|
||||
Without seeing the filed code in question, it's difficult to advise. Can you attach a document to a post with the field code and bookmark (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Sorry, here's the basic calculation I am using (I need to tell how many pages exist from a certain point to the end of the document):
{= {NUMPAGES} - {PAGEREF FirstSectionBreak }} If the bookmark 'FirstSectionBreak ' is renamed, or missing, I have seen either a syntax error, or some other error. I'd like to do something like this (pseudocode): {= {NUMPAGES} - (IF bookmarkExists{FirstSectionBreak }, {PAGEREF FirstSectionBreak }, 0 ) } |
#4
|
||||
|
||||
Try:
{IF{PAGEREF FirstSectionBreak}= "Error!*" 0 {={NUMPAGES}-{PAGEREF FirstSectionBreak}}}
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Quote:
This has just become an academic exercise for me; after spending a couple hours or so getting the parts that I have working, they just decided to remove the calculations I spent so much time working on. |
#6
|
||||
|
||||
Did you use Ctrl-F9 for all the field braces (i.e. { }) - you can't simply type them or copy & paste them from this forum. Also, the spaces indicated in the code I posted are all essential.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Quote:
And, now the client has done another 180, and decided to reinsert the calculations, so it's back to being a necessity. I swear, they act more like politicians than clients sometimes. I appreciate your assistance on this. |
#8
|
|||
|
|||
Quote:
Much appreciated! |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using multiple formulas in one (IF, AND and SUM) gives syntax error | markdeniet | Word | 1 | 02-05-2014 05:17 AM |
Automation error Unknown error" message once they open the Excel file | hlina | Excel | 1 | 10-08-2013 09:14 PM |
VLookup is giving me #N/A error, help with data or formula? | ladygogo78 | Excel | 3 | 10-22-2012 12:28 AM |
formula divide by serio error | vthomeschoolmom | Excel | 1 | 04-18-2012 02:29 PM |
Saveas error handling | jillapass | Word VBA | 7 | 03-30-2012 03:24 PM |