Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-21-2014, 01:55 PM
Cosmo Cosmo is offline Error handling in formula - suppress 'Syntax Error' Windows Vista Error handling in formula - suppress 'Syntax Error' Office 2007
Competent Performer
Error handling in formula - suppress 'Syntax Error'
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default 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?
Reply With Quote
  #2  
Old 02-21-2014, 02:22 PM
macropod's Avatar
macropod macropod is offline Error handling in formula - suppress 'Syntax Error' Windows 7 32bit Error handling in formula - suppress 'Syntax Error' Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 02-21-2014, 02:29 PM
Cosmo Cosmo is offline Error handling in formula - suppress 'Syntax Error' Windows Vista Error handling in formula - suppress 'Syntax Error' Office 2007
Competent Performer
Error handling in formula - suppress 'Syntax Error'
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

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 ) }
Reply With Quote
  #4  
Old 02-21-2014, 02:34 PM
macropod's Avatar
macropod macropod is offline Error handling in formula - suppress 'Syntax Error' Windows 7 32bit Error handling in formula - suppress 'Syntax Error' Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
{IF{PAGEREF FirstSectionBreak}= "Error!*" 0 {={NUMPAGES}-{PAGEREF FirstSectionBreak}}}
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 02-21-2014, 02:50 PM
Cosmo Cosmo is offline Error handling in formula - suppress 'Syntax Error' Windows Vista Error handling in formula - suppress 'Syntax Error' Office 2007
Competent Performer
Error handling in formula - suppress 'Syntax Error'
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Try:
{IF{PAGEREF FirstSectionBreak}= "Error!*" 0 {={NUMPAGES}-{PAGEREF FirstSectionBreak}}}
Thanks, I didn't quite have luck with that just yet, not sure if I am entering it correctly or not. I'm a bit of a novice using the fields & formulas in word, and I haven't qute gotten the hang of it yet.

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.
Reply With Quote
  #6  
Old 02-21-2014, 03:17 PM
macropod's Avatar
macropod macropod is offline Error handling in formula - suppress 'Syntax Error' Windows 7 32bit Error handling in formula - suppress 'Syntax Error' Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #7  
Old 02-21-2014, 03:24 PM
Cosmo Cosmo is offline Error handling in formula - suppress 'Syntax Error' Windows Vista Error handling in formula - suppress 'Syntax Error' Office 2007
Competent Performer
Error handling in formula - suppress 'Syntax Error'
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
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.
Yes, that was one of my first mistakes earlier today when I was trying to figure out how to do the simpler formulas. Getting the nested fields was an initial issue, but I was using Ctrl-F9 when I tested the updated formula. It's perhaps the 'IF' clause I was doing incorrectly. I will experiment with just that on Monday to see if I was entering it wrong.

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.
Reply With Quote
  #8  
Old 02-24-2014, 07:08 AM
Cosmo Cosmo is offline Error handling in formula - suppress 'Syntax Error' Windows Vista Error handling in formula - suppress 'Syntax Error' Office 2007
Competent Performer
Error handling in formula - suppress 'Syntax Error'
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Try:
{IF{PAGEREF FirstSectionBreak}= "Error!*" 0 {={NUMPAGES}-{PAGEREF FirstSectionBreak}}}
Thanks, I was able to finally get it working. I had to spend a few minutes working on just 'If' statement, got that working correctly, then rebuilt each part of the field one at a time.

Much appreciated!
Reply With Quote
Reply



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
Error handling in formula - suppress 'Syntax Error' Automation error Unknown error" message once they open the Excel file hlina Excel 1 10-08-2013 09:14 PM
Error handling in formula - suppress 'Syntax Error' VLookup is giving me #N/A error, help with data or formula? ladygogo78 Excel 3 10-22-2012 12:28 AM
Error handling in formula - suppress 'Syntax Error' formula divide by serio error vthomeschoolmom Excel 1 04-18-2012 02:29 PM
Error handling in formula - suppress 'Syntax Error' Saveas error handling jillapass Word VBA 7 03-30-2012 03:24 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:17 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft