View Single Post
 
Old 09-04-2021, 02:16 AM
Bikram Bikram is offline Windows 10 Office 2007
Advanced Beginner
 
Join Date: Jul 2021
Location: Nepal
Posts: 90
Bikram is on a distinguished road
Default

Thanks a lot for the reply, Sir. The code you provided worked awesomely and inserted the buildingblock I wanted to insert but
ActiveDocument.AttachedTemplate.BuildingBlockEntri es("heading").Insert Where:= _
Selection.Range, RichText:=True
still shows the error 5941.

For i = 1 To Templates(oTemplate.FullName).BuildingBlockEntries .Count
If Templates(oTemplate.FullName).BuildingBlockEntries (i).Name = strBuildingBlockName Then
Templates(oTemplate.FullName).BuildingBlockEntries (strBuildingBlockName).Insert _
Where:=Selection.Range
'set the found flag to true
bFound = True
'Clean up and stop looking
Set oTemplate = Nothing
GoTo lbl_Exit
End If
Next i
This part inserted the buildings blocks I needed. But when I tried
Dim oTemplate As Template
Set oTemplate = ActiveDocument.AttachedTemplate
Templates(oTemplate.FullName).BuildingBlockEntries ("heading").Insert _
Where:=Selection.Range
It again shows error 5941. Sir, can you please suggest what may have caused this problem and how can i solve this?
Reply With Quote