none
customdocprop format issue - Word 2007 VBA RRS feed

  • Question

  • I've a Word document with a customdocprop (cdp) named "cdpTest".

    I've formated the cdp: Bold, 14, Red, Arial

    When i use the code below only the "XXX" has de right format, the format has no effect on "YYY"

    ActiveDocument.CustomDocumentProperties("cdpTest").Value = "XXX YYY"    
        ActiveDocument.Fields.Update
    

    How can i solve this problem?

    Thursday, September 8, 2011 2:32 PM

Answers

  • Hi pacecal

    I'm not 100% sure exactly what you have, and it would also help to know the version of Word involved...

    My best guess is that you've inserted DocProperty fields into the document and are using them to display the content of CustomDocumentProperties stored in the document.

    If that's the case, then the issue is the way the field is coded.

    Press Alt+F9 to view the field codes in the document. You need the field switch \* CharFormat at the end of the field to force it to format the entire field result with the character formatting applied to the beginning of the field.

    If you see \* MergeFormat in the field code, delete it.

    Alt+F9 again to toggle the field codes off.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by pacecal987 Thursday, September 8, 2011 5:35 PM
    Thursday, September 8, 2011 2:52 PM
    Moderator

All replies

  • Hi pacecal

    I'm not 100% sure exactly what you have, and it would also help to know the version of Word involved...

    My best guess is that you've inserted DocProperty fields into the document and are using them to display the content of CustomDocumentProperties stored in the document.

    If that's the case, then the issue is the way the field is coded.

    Press Alt+F9 to view the field codes in the document. You need the field switch \* CharFormat at the end of the field to force it to format the entire field result with the character formatting applied to the beginning of the field.

    If you see \* MergeFormat in the field code, delete it.

    Alt+F9 again to toggle the field codes off.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by pacecal987 Thursday, September 8, 2011 5:35 PM
    Thursday, September 8, 2011 2:52 PM
    Moderator
  • Create ! :)

    It works!

    • Marked as answer by pacecal987 Thursday, September 8, 2011 5:35 PM
    • Unmarked as answer by pacecal987 Thursday, September 8, 2011 5:35 PM
    Thursday, September 8, 2011 5:34 PM