View Single Post
 
Old 04-10-2018, 05:29 AM
Charles Kenyon Charles Kenyon is offline Windows 10 Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,474
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Here is a macro that would insert the textbox formed using the instructions:
It assumes that both the building block and macro are stored in the same template.

Code:
Sub InsertMyBB()
    '
    ' Assumes that the Building Block is of the type AutoText (wdTypeAutoText)      in Category "General"
    ' See      https://msdn.microsoft.com/en-us/lib...ffice.12).aspx
    '
    ' This is based in part upon contributions from Greg Maxey and Jay Freedman      - any errors remain mine
    ' Written by Charles Kenyon February 2016
    '
   Dim sBBName As String
   Dim sTempName As String
   Dim oBB As BuildingBlock
   sBBName = "_MyText" 'use the name of your building block instead      of "_MyText"
   sTempName = ThisDocument.FullName ' puts name and full path of      template in string variable
   On Error Resume Next
   Set oBB = Application.Templates(sTempName).BuildingBlockTypes(wdTypeAutoText)      _
      .Categories("General").BuildingBlocks(sBBName)
   If Err.Number = 0 Then
      oBB.Insert Selection.Range, True
   Else
      MsgBox Prompt:="The Building Block '" & sBBName &      "' cannot be found in " & _
         ThisDocument.Name & ".",      Title:="Didn't Work!"
   End If
   On Error GoTo 0
lbl_Exit:
   Exit Sub
End Sub
You can download a template with this macro in it from my downloads page.
http://www.addbalance.com/word/downl...acroToInsertBB
Reply With Quote