locked
Hide Empty Document Properties in word 2016 RRS feed

  • Question

  • Hi,

    I am pulling through SharePoint list data into a word document using the document properties. I want the field to just be blank when the the property is empty, and show when the column contains data. Using the following IF statement It is nearly working, however when the field contains more than one word it seems to just display one of the words at random and not the whole field.

    {IF [Category] = "[Category]" "" "[Category]"}  (Where the ones in bold are the document property inserted via quick parts, and the non bold category is just typed in)

    If I change the [Category] property to be "Hello World" it becomes

    {IF [Hello World] = "[Category]" "" "[Hello World]"} - When I refresh and press alt F9, it only displays "World". If I set this document property to empty, it shows blank on the document as desired.

    Anyone know why this may be?

    Thanks in advance!

    Sunday, November 12, 2017 5:11 PM

Answers

  • You need quotation marks around the first comparand as well, e.g.

    { IF "[Category]" = "[Category]" "" "[Category]" } 


    Peter Jamieson

    • Marked as answer by NewtoSP2017 Monday, November 20, 2017 11:42 AM
    Friday, November 17, 2017 6:04 PM

All replies

  • Hi NewtoSP2017,

    I can see that you are adding the If condition.

    but you only posted the part of the IF condition.

    with the help of that we are not able to reproduce the issue on our side.

    I suggest you to post the full code with detailed steps to reproduce the issue.

    it will help us to understand the issue in better way.

    also let us know that are you using the VBA code or using the User Interface approach to bring the data in MS Word.

    This forum only handles the issues regarding Word VBA object model.

    so if you are using the User Interface approach then I can help you to move this thread to correct and best suitable forum. where you can get the solution for your issue.

    so please try to provide above mentioned information. we will try to provide you further suggestions to solve the issue.

    Thanks for your understanding.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 13, 2017 3:08 AM
  • Hi,

    I am not using the VBA object model, so could you please help me move it over :)

    Thanks,
    Monday, November 13, 2017 10:13 AM
  • Hi NewtoSP2017,

    I move this thread to Word it pro discussions forum.

    further MSDN support Engineers for that forum will try to provide you the suggestions to solve the issue.

    Thanks for your understanding.

    Regards

    Deepak


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, November 14, 2017 2:51 AM
  • Hello,

    >>I am pulling through SharePoint list data into a word document using the document properties. 

    Could you provide the detailed steps to achieve this so that we can try to reproduce this issue in our environment? If you need to include some screenshots however you cannot upload images in this forum currently, you can share the images to us via sending to GBSD TN Office Information Collection ibsofc@microsoft.com, which is used to collect information only. (Please include the thread URL in the message so that we can follow up on it in time)

    Thank you for your understanding and patience. 

    Regards,

    Steve Fan


    Please remember to mark the replies as answers if they helped.
    If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Friday, November 17, 2017 3:03 AM
  • Hello,

    I am having the same issue even when not doing this.

    If I load up a blank word document, and use the default document properties ie company or category then it displays correctly if I insert the data as one word. However if I try and enter Hello World, it is only the second word "world" that displays. So I don't think It is anything to do with how the document properties are pulled through from SP. It just seems to be an Issue with how I have formatted the IF statement.

    Let me know if you require any further information.

    Thanks,
    Friday, November 17, 2017 3:24 PM
  • You need quotation marks around the first comparand as well, e.g.

    { IF "[Category]" = "[Category]" "" "[Category]" } 


    Peter Jamieson

    • Marked as answer by NewtoSP2017 Monday, November 20, 2017 11:42 AM
    Friday, November 17, 2017 6:04 PM
  • This has done it! Thank you so much

    Monday, November 20, 2017 11:42 AM