Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-23-2018, 12:33 PM
Cosmo Cosmo is offline Field Code: Show a value only if bookmark is not empty Windows Vista Field Code: Show a value only if bookmark is not empty Office 2007
Competent Performer
Field Code: Show a value only if bookmark is not empty
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default Field Code: Show a value only if bookmark is not empty

I rarely have to delve into the pain that is MS Word Field Codes, and whenever I do, I end up pulling my hair out.

I need to have show a value ONLY if a bookmark is NOT empty.



I tried using a COMPARE, but it only seems to work if I specify the EXACT value (e.g. "Test"). If I compare it to an empty string (""), it doesn't work. The following code:

{COMPARE{REF TestBookmark} = "Test"}

gives me a result of 1 if 'TestBookmark' does equal "Test". But if I try to use the following:

{COMPARE{REF TestBookmark} = ""}

I always get a 0 result.

Is there any way to tell if a Bookmark is empty?

What I'm looking for is something like this:

{IF{={COMPARE{REF TestBookmark} = ""} > 0} "Bookmark Is Empty" "Bookmark Is NOT Empty"}
Reply With Quote
  #2  
Old 08-23-2018, 02:23 PM
macropod's Avatar
macropod macropod is offline Field Code: Show a value only if bookmark is not empty Windows 7 64bit Field Code: Show a value only if bookmark is not empty Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

{IF{REF TestBookmark}<> "" "Conditional Output"}
or:
{IF{REF TestBookmark}= "" "" "Conditional Output"}
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 08-23-2018, 03:15 PM
Cosmo Cosmo is offline Field Code: Show a value only if bookmark is not empty Windows Vista Field Code: Show a value only if bookmark is not empty Office 2007
Competent Performer
Field Code: Show a value only if bookmark is not empty
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
{IF{REF TestBookmark}<> "" "Conditional Output"}
or:
{IF{REF TestBookmark}= "" "" "Conditional Output"}
Thanks. I’ll check that tomorrow when I’m back in the office. I thought I tried both of those options, but I might have not had the exact correct syntax.
Reply With Quote
  #4  
Old 08-23-2018, 08:35 PM
Charles Kenyon Charles Kenyon is offline Field Code: Show a value only if bookmark is not empty Windows 10 Field Code: Show a value only if bookmark is not empty Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

I believe the spaces can matter.
Reply With Quote
  #5  
Old 08-23-2018, 08:44 PM
macropod's Avatar
macropod macropod is offline Field Code: Show a value only if bookmark is not empty Windows 7 64bit Field Code: Show a value only if bookmark is not empty Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Yes, but that wasn't an issue with the field codes Cosmo posted and isn't an issue with those I've posted; mine have the minimum allowable spaces.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 08-24-2018, 06:16 AM
Cosmo Cosmo is offline Field Code: Show a value only if bookmark is not empty Windows Vista Field Code: Show a value only if bookmark is not empty Office 2007
Competent Performer
Field Code: Show a value only if bookmark is not empty
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Yes, but that wasn't an issue with the field codes Cosmo posted and isn't an issue with those I've posted; mine have the minimum allowable spaces.
I wouldn't necessarily count that out, as I may have typed it differently in my post here than I had entered it in the document. Wasn't aware that the spaces could be an issue.

Thanks.
Reply With Quote
  #7  
Old 08-24-2018, 06:27 AM
Cosmo Cosmo is offline Field Code: Show a value only if bookmark is not empty Windows Vista Field Code: Show a value only if bookmark is not empty Office 2007
Competent Performer
Field Code: Show a value only if bookmark is not empty
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Ok, I figured out my problem - it wasn't due to any errors with the field codes (surprisingly), it was the value I was referring to by the bookmark name was a text Form Field. Apparently the text field doesn't evaluate to an empty string in the comparison, or something like that.

Problem solved, and I learned a few things here. Thanks.
Reply With Quote
  #8  
Old 08-24-2018, 01:46 PM
Charles Kenyon Charles Kenyon is offline Field Code: Show a value only if bookmark is not empty Windows 10 Field Code: Show a value only if bookmark is not empty Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

You are welcome.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bookmark will not show/hide based on CC Checkbox lord_kaiser Word VBA 1 04-17-2018 01:19 AM
loop code until the first empty row altina Excel Programming 0 03-24-2017 06:49 PM
Field Code: Show a value only if bookmark is not empty VBA Code to search for field codes with certain text before the Field code and to change style welcometocandyland Word VBA 4 02-08-2017 06:53 PM
Find Bookmark, move to bookmark, execute code, repeat raymm3852 Word VBA 10 04-15-2016 06:21 PM
Field Code: Show a value only if bookmark is not empty Delete Line of Bookmark if the Text is Empty ljg713 Word VBA 1 12-21-2015 04:27 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:35 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