I'm trying to add a custom building block at the click of a button in MS word 10. Below is the code currently attached to my activeX button.
Private Sub CommandButton1_Click()
Dim objTemplate As Template
Dim objBB As BuildingBlock
' Set the template to store the building block
Set objTemplate = ActiveDocument.AttachedTemplate
' Access the building block through the type and category
Set objBB = objTemplate.BuildingBlockTypes(wdTypeCustom5) _
.Categories("General").BuildingBlocks("Experience")
' Insert the building block into the document replacing any selected text.
objBB.Insert Selection.Range
End Sub
My problem is, as this code is invoked at the click of a button, the button becomes the "Selection.Range" and is thus replaced. I looked all around for alternate codes that mention of different "where" specification and found nothing.
I only found two links(can't find the urls in my history rightnow, will update shortly)
It mentioned "Paragraphs(1)" instead of "Selection.Range", but this is an absolute location while I would need something relative (Before the button)
Using InsertBefore method which I suppose applies only to text (it was used to insert text in the example) as when I tried it for building blocks it didnt work
P.S I'm relatively new to VBA