none
Add content control with link to document property RRS feed

  • Question

  • hello

    I searched carefully in the web but cannot end up with an answer.

    I need to add a ContentControl with VBA but the problem is how to link it to a built-in document property ("Title" in my case).

    In other words: how to do with VBA this steps: Insert > Quick parts > Document property > Title ??

    thanks

    Thursday, August 21, 2014 7:34 AM

Answers

  • Hi Liederman,

    The document property is a plain text content control and bind to the title property story in the document. Here is a sample for your reference:

    Sub AddTitleQuickPart()
    
    Dim objCC As ContentControl
    Dim objMap As XMLMapping
    Dim blnMap As Boolean
     
    ActiveDocument.BuiltInDocumentProperties("Title").Value = "This is a title"
    Set objCC = ActiveDocument.ContentControls.Add(wdContentControlText)
     
    objCC.Title = "Title"
     
    Set objMap = objCC.XMLMapping
    blnMap = objMap.SetMapping(XPath:="/ns1:coreProperties[1]/ns0:title[1]")
     
    If blnMap = False Then
     MsgBox "Unable to map the content control."
    End If
    
    
    End Sub
    

    Here are some helpful links for your reference:
    ContentControl.XMLMapping Property (Word)

    How to: Bind a Content Control to a Node in the Data Store

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, August 22, 2014 2:44 AM
    Moderator