View Single Post
 
Old 12-16-2019, 09:12 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

The macro and the building block should reside in the same template file. This reduces complexity when you need to distribute both to other users.

The code that is pointing at ActiveDocument.AttachedTemplate assumes you actually placed the building block in that template. The acceptable values for BuildingBlockTypes are shown on this page WdBuildingBlockTypes enumeration (Word) | Microsoft Docs

So if you saved the building block in the attached template as an AutoText, with a category of General and a name of Table then the following line should work
Code:
ActiveDocument.AttachedTemplate.BuildingBlockTypes(wdTypeAutoText).Categories("General").BuildingBlocks("Table").Insert Where:=Selection.Range, RichText:=True
If that was all you were putting in the macro, you could just type the word Table and then press F3 to insert the same
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote