Consulting

Results 1 to 3 of 3

Thread: Word Field code IF - Else backspace?

  1. #1
    VBAX Regular
    Joined
    May 2012
    Posts
    22
    Location

    Word Field code IF - Else backspace?

    Hi,

    I have a docx-document that has fields like this
    Listed here are our customers
    Customer1
    Customer2
    Customer3
    Customer4
    Customer5
    And that's the customers we have
    The field formula is (on pseudolevel): IF { {DOCPROPERTY "Customer1"} <> "Error! Unknown document property name." {DOCPROPERTY "Customer1"} " ""}
    which basically works, but I don't like the idea that with one customer it looks like this:
    Listed here are our customers
    Customer1
    
    
    
    
    And that's the customers we have
    because it has disturbing empty lines, and it should instead look like:
    Listed here are our customers
    Customer1
    And that's the customers we have
    So is there a way to give on that else-branch a command of backspace i.e. delete the entire line if no value exists?

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    3,585
    Location
    The solution is as simple as putting the paragraph break into the IF test:
    {IF{DOCPROPERTY "Customer1"} <> "Error!*" "{DOCPROPERTY "Customer1"}
    "}{IF{DOCPROPERTY "Customer2"} <> "Error!*" "{DOCPROPERTY "Customer2"}
    "}{IF{DOCPROPERTY "Customer3"} <> "Error!*" "{DOCPROPERTY "Customer3"}
    "}
    etc.
    Cheers
    Paul Edstein
    [MS MVP - Word]

  3. #3
    VBAX Regular
    Joined
    May 2012
    Posts
    22
    Location
    Quote Originally Posted by macropod View Post
    The solution is as simple as putting the paragraph break into the IF test:
    {IF{DOCPROPERTY "Customer1"} <> "Error!*" "{DOCPROPERTY "Customer1"}
    "}{IF{DOCPROPERTY "Customer2"} <> "Error!*" "{DOCPROPERTY "Customer2"}
    "}{IF{DOCPROPERTY "Customer3"} <> "Error!*" "{DOCPROPERTY "Customer3"}
    "}
    etc.
    Oh nice! I haven't tested this yet, but sounds logical.

    Thanks!

Posting Permissions

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