Hello, I have a text box building block in a template in my STARTUP folder. I am able to insert it into the document via VBA. But, once inserted, I need to be able to select it and modify things like the fill color. However, I am unable to figure out how to select it once it has been inserted.
The building block is a text box that is wrapped tight with the text. The property of the building block is set to "Insert Contents Only." So, once inserted, the text box is anchored to the paragraph in which the cursor resides at the time of insertion. The text box is automatically positioned to the right of the paragraph in which the cursor resides at the time of insertion. Insertion is accomplished via the text context menu XML callback to a VBA module.
The text box is considered to be a shape, right? Is there a way to find and select the shape that is attached to the current paragraph immediately after insertion?
I am using Word 2016.
Code follows. I modified a few things to make it public (indicated by use of brackets).
Any help would be most appreciated.
Thanks for your consideration.
Doug

'Callback for ctxbtnTextBox onActionSub ctxInsertTextBox_click(control As IRibbonControl)
    Dim MyTemplate As Template
    Dim MyBB As BuildingBlock
    Dim myPath As String
    myPath = Application.StartupPath & "\[this is my template].dotm"
    'Set the template to the one that holds the building block
    Set MyTemplate = Templates(myPath)
    
    'Access the building block through the type and category
    Set MyBB = MyTemplate.BuildingBlockTypes(wdTypeQuickParts) _
    .Categories("[my category]").BuildingBlocks("[My Text Box]")
    
    'Insert the BB
    MyBB.Insert Selection.range
    
    'Select the BB just inserted
    'TBD
End Sub