Excel Hints

Results 1 to 3 of 3

Thread: Run-time error '5941': The requested member of the collection does not exist.

  1. #1

    Run-time error '5941': The requested member of the collection does not exist.

    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?


    [vba]
    Sub Insert_Footer()

    WordBasic.ViewFooterOnly
    ActiveDocument.AttachedTemplate.BuildingBlockEntries("Alphabet").Insert _
    Where:=Selection.Range, RichText:=True

    End Sub

    [/vba]

    Thanks

  2. #2
    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:

    [VBA]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
    [/VBA]

  3. #3
    Quote Originally Posted by gmaxey
    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:

    [vba]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
    [/vba]
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •