Consulting

Results 1 to 3 of 3

Thread: Word Field code IF - Else backspace?

  1. #1

    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
    
    
    Formatting tags added by mark007
    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
    
    
    Formatting tags added by mark007
    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
    
    
    Formatting tags added by mark007
    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,187
    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
    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
  •