![]() |
#1
|
|||
|
|||
![]()
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"} |
#2
|
||||
|
||||
![]()
{IF{REF TestBookmark}<> "" "Conditional Output"}
or: {IF{REF TestBookmark}= "" "" "Conditional Output"}
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
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.
|
#4
|
|||
|
|||
![]()
I believe the spaces can matter.
|
#5
|
||||
|
||||
![]()
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] |
#6
|
|||
|
|||
![]() Quote:
Thanks. |
#7
|
|||
|
|||
![]()
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. |
#8
|
|||
|
|||
![]()
You are welcome.
|
![]() |
|
![]() |
||||
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 |
![]() |
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 |
![]() |
ljg713 | Word VBA | 1 | 12-21-2015 04:27 PM |