View Full Version : Run-time error '5941': The requested member of the collection does not exist.
uktous
09-02-2012, 03:46 AM
Hi,
I recorded the following macro.
The macro can insert a footer.
However, when I run it again, it does not work.
I got the following message
Run-time error '5941':
The requested member of the collection does not exist.
How can I solve this problem?
Sub Insert_Footer()
WordBasic.ViewFooterOnly
ActiveDocument.AttachedTemplate.BuildingBlockEntries("Alphabet").Insert _
Where:=Selection.Range, RichText:=True
End Sub
Thanks
gmaxey
09-02-2012, 05:57 AM
That would seem to indicate that the buildingblock is not available. Are you running it again repeatedly in the same document or are you trying to run it in a new document that may not have the same attached template or building blocks?
Try:
Sub Insert_Footerh()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
oRng.Collapse wdCollapseStart
ActiveDocument.AttachedTemplate.BuildingBlockEntries("alphabet).Insert _
Where:=oRng, RichText:=True
End Sub
uktous
09-02-2012, 08:08 AM
That would seem to indicate that the buildingblock is not available. Are you running it again repeatedly in the same document or are you trying to run it in a new document that may not have the same attached template or building blocks?
Try:
Sub Insert_Footerh()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
oRng.Collapse wdCollapseStart
ActiveDocument.AttachedTemplate.BuildingBlockEntries("alphabet).Insert _
Where:=oRng, RichText:=True
End Sub
Hi,
your macro does not work as well.
I tried to run it again repeatedly in the same document and also tried to run it in a new document.
I think that attached template or building blocks does exist.
However, the macro is the able to "get" the template / building block.
If so, how can i solve it?
Thanks
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.