Results 1 to 10 of 10
  1. #1
    3 Star Lounger
    Join Date
    Mar 2009
    Location
    Hong Kong
    Posts
    359
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If a book is set to null, say, {SET FileDate }
    How can I test if {FileDate} is a null string?
    {IF {FileDate}=?? "Yes" "No"}
    Thanks.
    Armstrong

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts
    [quote name='armsys' post='765994' date='18-Mar-2009 11:08']If a book is set to null, say, {SET FileDate }
    How can I test if {FileDate} is a null string?
    {IF {FileDate}=?? "Yes" "No"}
    Thanks.
    Armstrong[/quote]
    Try
    { IF{REF "FileDate" }="" "Yes" "No" }
    Note: You may want to use nested IF fields to check if the bookmark gives you "Error! Reference source not found."

  3. #3
    3 Star Lounger
    Join Date
    Mar 2009
    Location
    Hong Kong
    Posts
    359
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Stuart,
    Thanks a lot.
    Armstrong

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='armsys' post='766037' date='19-Mar-2009 02:33']Stuart,
    Thanks a lot.
    Armstrong[/quote]
    Hi Armstrong,

    Depending on what you're after, here's other two possible ways:
    {={FILEDATE \@ DDMMYYYY} \# "Yes;;No"}
    or
    {={FILEDATE \@ DDMMYYYY} \# "00'-'00'-'0000;;No"}
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    3 Star Lounger
    Join Date
    Mar 2009
    Location
    Hong Kong
    Posts
    359
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi Macropod,
    I'm honored to receive your reply. I read a lot of your high value articles on Word fields. I learn a great deal from you. You're only the one, not Microsoft, in the world telling me explicitly that AND(), OR(), NOT(), can IF() can't compare text strings. That's awesome.
    For the current question, in a legal brief, I would like show Filing Date instead if the Application Date is missing (ie, undefined).
    {SET AppDate}{SET FileDate 3/19/2009}
    In this case, what's the best approach?
    Thanks for your help.

    Armstrong

  6. #6
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='armsys' post='766154' date='19-Mar-2009 18:02']Hi Macropod,
    I'm honored to receive your reply. I read a lot of your high value articles on Word fields. I learn a great deal from you. You're only the one, not Microsoft, in the world telling me explicitly that AND(), OR(), NOT(), can IF() can't compare text strings. That's awesome.
    For the current question, in a legal brief, I would like show Filing Date instead if the Application Date is missing (ie, undefined).
    {SET AppDate}{SET FileDate 3/19/2009}
    In this case, what's the best approach?
    Thanks for your help.

    Armstrong[/quote]
    Hi Armstrong,

    Thanks for the compliment.

    If your field codes really are as you've posted (ie {SET AppDate}{SET FileDate 3/19/2009}), and don't have double quotes enclosing the bookmark values, you could use a formula field with an IF test coded as:
    {IF{REF AppDate}= "Err*" {REF FileDate} {REF AppDate}}

    If you do have double quotes enclosing the bookmark values (ie {SET AppDate ""}{SET FileDate "3/19/2009"}), you could use a formula field with an IF test coded as:
    {IF{REF AppDate}= "" {REF FileDate} {REF AppDate}}
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  7. #7
    3 Star Lounger
    Join Date
    Mar 2009
    Location
    Hong Kong
    Posts
    359
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='macropod' post='766167' date='19-Mar-2009 18:48']Hi Armstrong,

    Thanks for the compliment.

    If your field codes really are as you've posted (ie {SET AppDate}{SET FileDate 3/19/2009}), and don't have double quotes enclosing the bookmark values, you could use a formula field with an IF test coded as:
    {IF{REF AppDate}= "Err*" {REF FileDate} {REF AppDate}}

    If you do have double quotes enclosing the bookmark values (ie {SET AppDate ""}{SET FileDate "3/19/2009"}), you could use a formula field with an IF test coded as:
    {IF{REF AppDate}= "" {REF FileDate} {REF AppDate}}[/quote]
    Hi Paul,
    Thanks for telling me about the "Err*" thing. I have never read a single book (Inside Out/Beyond the Manual/Bible,...etc.) on Word 2003/2007 revealing such secret. That's amazing.
    Actually, there's one more possibility. The Bookmark is completely undefined. That's, it isn't even defined in any {SET} field code. Then, how should I cope with this "worst" scenario?

    Actually, {SET AppDate} causes no trouble in Word 2007. Before your enlightenment, I wrote the following clumsy code:
    {SET NUL}{SET AddDate}{If {AddDate} = {NUL} "Print This" "Print That"}, which isn't as elegant as yours, of course.

    Armstrong

  8. #8
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='armsys' post='766175' date='19-Mar-2009 22:13']Hi Paul,
    Thanks for telling me about the "Err*" thing. I have never read a single book (Inside Out/Beyond the Manual/Bible,...etc.) on Word 2003/2007 revealing such secret. That's amazing.
    Actually, there's one more possibility. The Bookmark is completely undefined. That's, it isn't even defined in any {SET} field code. Then, how should I cope with this "worst" scenario?

    Actually, {SET AppDate} causes no trouble in Word 2007. Before your enlightenment, I wrote the following clumsy code:
    {SET NUL}{SET AddDate}{If {AddDate} = {NUL} "Print This" "Print That"}, which isn't as elegant as yours, of course.

    Armstrong[/quote]
    Hi Armstrong,

    The first version of the field code (ie {IF{REF AppDate}= "Err*" {REF FileDate} {REF AppDate}}) will handle a missing AppDate bookmark just as well - since that's what {SET AppDate} amounts to.

    The ' "Err*" thing' you refer to is simply string testing with a wildcard - it saves testing the full output. I think you'll find examples of this in some of the field codes in my Date Calc tutorial.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  9. #9
    3 Star Lounger
    Join Date
    Mar 2009
    Location
    Hong Kong
    Posts
    359
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='macropod' post='766181' date='19-Mar-2009 19:27']The ' "Err*" thing' you refer to is simply string testing with a wildcard - it saves testing the full output. I think you'll find examples of this in some of the field codes in my Date Calc tutorial.[/quote]
    Hi Paul,
    The more you talk, the more I'm humbled. Wait a minute, do you mean {IF} can do wildcard comparisons? Do you mean "wildcard" in the same sense as found in "Find and Replace"? Definitely I've to re-study your Date Calc tutorial. Thanks.
    Armstrong

  10. #10
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    [quote name='armsys' post='766187' date='19-Mar-2009 23:10']Hi Paul,
    The more you talk, the more I'm humbled. Wait a minute, do you mean {IF} can do wildcard comparisons? Do you mean "wildcard" in the same sense as found in "Find and Replace"? Definitely I've to re-study your Date Calc tutorial. Thanks.
    Armstrong[/quote]
    Hi Armstrong,

    Nothing so sophisticated as you get with Word's "Find and Replace", unfortunately - just the good old '*' and '?' wilcards, for 'any string' and 'any character', respectively.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •