Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-10-2016, 01:45 AM
Katherine1995 Katherine1995 is offline Run-time error '-2147467259 (80004005)': Method 'Insert' of object 'BuildingBlock' failed Windows 10 Run-time error '-2147467259 (80004005)': Method 'Insert' of object 'BuildingBlock' failed Office 2016
Novice
Run-time error '-2147467259 (80004005)': Method 'Insert' of object 'BuildingBlock' failed
 
Join Date: Nov 2016
Posts: 4
Katherine1995 is on a distinguished road
Question Run-time error '-2147467259 (80004005)': Method 'Insert' of object 'BuildingBlock' failed

I am getting the following error on the 2nd click on the command button.



Run-time error '-2147467259 (80004005)': Method 'Insert' of object 'BuildingBlock' failed

I am trying to insert the same building block at a bookmark on the click of the command button. It inserts the block successfully during the 1st click. But, on the 2nd click, the above error occurs.

Here is my code:

Code:
Private Sub ClickToAddButton_Click()

 Dim objTemplate As Template
     Dim objBB5 As BuildingBlock
     Dim BBName As String 'Building Block String
     Dim BM1 As String 'Bookmark String
     Dim Rng5, Rng5t As Range
       
    BM1 = "Bookmark1"
    Set objTemplate = ActiveDocument.AttachedTemplate
    Set Rng5 = ActiveDocument.Bookmarks(BM1).Range
    Set Rng5t = Rng5.Duplicate
    Rng5.Collapse wdCollapseEnd
        
      BBName = "MyBuildingBlock"
                       
Set objBB5 = objTemplate.BuildingBlockTypes(wdTypeAutoText).Categories("General").BuildingBlocks(BBName)

'INSERT Building BLOCK
objBB5.Insert Rng5, True              

 'After every INSERT of Building block -- reset the range variable & Re-Insert Bookmark
 Rng5.Start = Rng5t.Start
 ActiveDocument.Bookmarks.Add BM1, Rng5
           
End Sub
Can anyone point out what is wrong with my code?
Any help is appreciated.

TIA
Reply With Quote
 

Tags
bookmark, building blocks, insert



Similar Threads
Thread Thread Starter Forum Replies Last Post
ADODB import of Excel data results in "Run-time error -2147467259: <sheet> is not a valid name." misaak Excel Programming 3 06-20-2016 07:55 AM
Run-time error '-2147467259 (80004005)': Method 'Insert' of object 'BuildingBlock' failed Run-time error '424': Object required zlodeh Excel Programming 1 02-24-2016 01:58 AM
Run time error - Pivot Cache Failed patrick1063 Excel Programming 0 02-08-2016 07:56 PM
Run-time error '-2147467259 (80004005)': Method 'Insert' of object 'BuildingBlock' failed Run Time Error 424 - Object Required Doug Needham Excel Programming 4 01-12-2015 10:54 PM
OUTLOOK : the operation failed. an object cannot be found luotzabl Outlook 0 02-28-2010 02:48 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:09 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