![]() |
|
|
Thread Tools | Display Modes |
#2
|
||||
|
||||
![]()
It is easy enough to determine whether the selection is in a table and if it is to select one of the cells in that table and set the range to that cell's content. e.g.
Code:
Sub Macro1() Dim WrdTemplate As Template Dim objBB As BuildingBlock Dim WrdRng As Range Set WrdRng = Selection.Range If WrdRng.Information(wdWithInTable) = True Then 'the selection is in a table Set WrdRng = Selection.Cells(1).Range 'the first cell in the selection WrdRng.End = WrdRng.End - 1 'omit the end of cell character from the range End If Set WrdTemplate = Application.Templates("filepath") Set objBB = WrdTemplate.BuildingBlockTypes(wdTypeCustom1).Categories("Legislation").BuildingBlocks("END") objBB.Insert WrdRng Set objBB = Nothing Set WrdRng = Nothing Set WrdTemplate = Nothing End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
chriscla | Word VBA | 16 | 04-04-2020 10:41 PM |
Error Handler If User Does Not Want to Overwrite File | ChrisOK | Excel Programming | 4 | 04-03-2020 08:31 PM |
Error when inserting Quick Table created | taryn | Word | 2 | 09-11-2017 05:44 AM |
Formatting Issues When Using If Statements and Inserting Building Blocks/Autotext | sanko787 | Mail Merge | 1 | 07-05-2014 09:00 PM |
![]() |
rollno | Word | 7 | 02-24-2014 04:29 PM |