Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Mar 2010
    Location
    Pennsylvania
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I need to write an IF statement in Word 2003 that compares the same field against multiple values. Is there a Word function that can be used to set the condition as something like IF FIELDNAME = any one of ("Joe", "Fred", "Sam")? Thanks.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Quote Originally Posted by Dawn Cureton View Post
    I need to write an IF statement in Word 2003 that compares the same field against multiple values. Is there a Word function that can be used to set the condition as something like IF FIELDNAME = any one of ("Joe", "Fred", "Sam")?
    Is this using Word's fields or in VBA? (I know how to do this in VBA, but not with Word fields.)

  3. #3
    New Lounger
    Join Date
    Mar 2010
    Location
    Pennsylvania
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Unfortunately, it has to be from within Word. Thanks.

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    3,944
    Thanks
    0
    Thanked 203 Times in 184 Posts
    Hi Dawn,

    You don't say what kinds of fields you're working with or what it is you're trying to achieve with them. Here's an example for the document's 'author' property to return True or False:
    {IF{={IF{DOCPROPERTY Author \* Upper}= "JOE" 1 0}+{IF{DOCPROPERTY Author \* Upper}= "FRED" 1 0}+{IF{DOCPROPERTY Author \* Upper}= "SAM" 1 0}}= 1 "TRUE" "FALSE"}
    The field code returns 'True' if any of the authors is named Joe, Fred or Sam.

    Note: The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste them from this message.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    New Lounger
    Join Date
    Mar 2010
    Location
    Pennsylvania
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's not quite what I was hoping for, but this format is a lot more streamlined than the multi-layered IF I thought I would have to use. Thanks for your help.

Posting Permissions

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