Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #11  
Old 04-10-2018, 05:29 AM
Charles Kenyon Charles Kenyon is offline Macro-inserting text box Windows 10 Macro-inserting text box Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,529
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro-inserting text box Macro for inserting and formatting headers and footers Mike_Lennox Word VBA 4 10-06-2016 12:10 AM
Macro-inserting text box Need Macro for Find and Replace, Inserting logo in Ms-Word. Aswinraj Word VBA 1 06-05-2016 04:33 PM
Macro-inserting text box 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
Macro-inserting text box Inserting key strokes with a macro line ACA Word VBA 4 12-03-2012 04:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:25 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft