![]() |
|
#11
|
|||
|
|||
|
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
http://www.addbalance.com/word/downl...acroToInsertBB |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Macro for inserting and formatting headers and footers
|
Mike_Lennox | Word VBA | 4 | 10-06-2016 12:10 AM |
Need Macro for Find and Replace, Inserting logo in Ms-Word.
|
Aswinraj | Word VBA | 1 | 06-05-2016 04:33 PM |
Inserting and rearranging text by inspecting existing text
|
rok123 | Word VBA | 9 | 02-05-2016 07:31 PM |
| Macro for Inserting Cross-referenced Continuation Headings | rdross51 | Word VBA | 0 | 01-06-2016 10:20 PM |
Inserting key strokes with a macro line
|
ACA | Word VBA | 4 | 12-03-2012 04:40 AM |