Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-12-2025, 11:48 PM
ausswe ausswe is offline Display a message warning when a cross referenced bookmark returns an Error Windows 11 Display a message warning when a cross referenced bookmark returns an Error Office 2021
Novice
Display a message warning when a cross referenced bookmark returns an Error
 
Join Date: Mar 2025
Location: Sweden
Posts: 1
ausswe is on a distinguished road
Default Display a message warning when a cross referenced bookmark returns an Error

Hi,


I have a template that contains a number of bookmarks to populate information from a system when the Word file is created. These bookmarks are formatted with a white font as it is being read by a software and not to be printed out if the file is printed.

The bookmarks contain information about the recepients address etc and I'm trying to figure out a way to warn the user if any of the "hidden" bookmarks ends up with an error.

I have tried to create a separate bookmark called "DokA_ID" which spans over all bookmarks with address information.

I then created a cross reference in the document with a suggested code that I found online:
Code:
{ IF { REF DokA_ID } = "" "Error! Bookmark not defined." }
That ended up displaying "REF" instead of the result of the bookmark, I then changed the field code to {REF DokA_ID} (removing the space between after/before the brackets. That ended up displaying "DokA_ID}". Finally I removed the space between "REF" and "DokA_ID" which ended up with the result being just blank - no output.

I then tried to rename the bookmark to "DokA_ID2" in order to test if the error message would be displayed but with no luck.

Does anyone have any suggestions on how to acheive this check with an IF statement? I can't use VBA as the templates are uploaded to a system that don't allow for VBA documents.

I have tried various IF statements previosly and never managed to get them to work.
Reply With Quote
  #2  
Old 04-13-2025, 04:30 AM
macropod's Avatar
macropod macropod is offline Display a message warning when a cross referenced bookmark returns an Error Windows 10 Display a message warning when a cross referenced bookmark returns an Error Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,343
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

Given that the information isn't to be printed, why are you writing into the document instead of populating document variables or custom document properties? Far simpler than writing to bookmarks.

As for your field coding, none of the field braces (i.e. {}) can be typed, which is what your problem description suggests you're doing. They should be created (in pairs) by pressing Ctrl-F9.

Regardless, the field code you're trying to use probably won't work the way you want it to. As coded, it returns an error message if the bookmark contains no data - which can be a perfectly valid result; it certainly doesn't mean what your output message suggests.

If the problem is you're trying to deal with is that a bookmark has been deleted (which poor coding or a user can do all too easily), Word will already display:
Error! Reference source not found.
So, if that's what you're trying to suppress, your field coding should be along the lines of:
{IF{REF BkMk} = "Error!*" "" {REF BkMk}}

None of this would be necessary if your document used document variables, especially, or custom document properties. The advantage of using document variables is that users can't delete them. Then, all your document needs instead of bookmarks and REF fields is just a set of DOCVARIABLE or DOCPROPERTY fields.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
error, field code, ref



Similar Threads
Thread Thread Starter Forum Replies Last Post
Display a message warning when a cross referenced bookmark returns an Error Macro to delete cross-reference error message when bookmark deleted grahamsims Word 8 12-03-2020 10:50 AM
Word 2007 - Document returns to first page without warning and does not save last edits. paulbasel Word 11 12-16-2018 04:36 PM
Display a message warning when a cross referenced bookmark returns an Error Hide error message from missing bookmark lodi123 Word 2 03-28-2017 11:24 PM
Problem opening Outlook Today. Error Message: Cannot display the folder. Cannot find this file. Veri atwnsw Outlook 0 11-01-2015 05:05 PM
Microsoft Office 2010 programs display error message "Application has failed to start SamSR Office 1 02-15-2011 07:15 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:31 PM.


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