Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-07-2022, 03:29 AM
LSLSLS LSLSLS is offline error handler: inserting building blocks when multiple cells in a table are selected creates error Windows 10 error handler: inserting building blocks when multiple cells in a table are selected creates error Office 2016
Novice
error handler: inserting building blocks when multiple cells in a table are selected creates error
 
Join Date: Jan 2022
Posts: 2
LSLSLS is on a distinguished road
Default error handler: inserting building blocks when multiple cells in a table are selected creates error

Hello and Happy New Year.



First of all, I'm new to this (as I'm sure you can see), but trying to learn as best I can, by doing. I have hit a wall, however.

I have a macro which inserts a building block from my custom library when a button is clicked in the ribbon in word (button added using Custom UI Editor).

This works fine, though if a user has mistakenly selected a number of cells in a Table in the word document and tries to insert the building block, it creates an error (see figure attached).

My approach set out below.

Sub Macro1()

Dim WrdTemplate As Template
Dim objBB As BuildingBlock
Dim WrdRng As Range

Set WrdTemplate = Application.Templates("filepath")

Set objBB = WrdTemplate.BuildingBlockTypes(wdTypeCustom1).Cate gories("Legislation").BuildingBlocks("END")

objBB.Insert Selection.Range
End Sub



I tried to get around this by changing

objBB.Insert Selection.Range

to

objBB.Insert ActiveDocument.Range

and this does avoid the error, though it overwrites the last building block I added and I need to be able to add multiple.

Is there a way to handle this error so that, if a user has selected multiple cells in a table and they try to insert a building block there, an error box comes up and prevents the action?

Many thanks
Attached Images
File Type: png error.png (3.7 KB, 12 views)
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
error handler: inserting building blocks when multiple cells in a table are selected creates error Multiple entries in dropdown lists with building blocks 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
error handler: inserting building blocks when multiple cells in a table are selected creates error Open Quickpart file normalemail.dotm - edit multiple building blocks rollno Word 7 02-24-2014 04:29 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:07 PM.


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