none
Run-time error '5941' the requested member of the collection does not exist

    Question

  • I have followed Greg's instructions for check boxes on http://gregmaxey.mvps.org/Add_Toggle_Objects.htm but when I double click on the box it gives me the run time error. I have saved as a template (.dotm) and then saved document as a .docm but always get the same error. Would love this to work as I can not have both controls and legacy form controls in same document - good on you microsoft!

    Any help would be great.

    Wednesday, July 07, 2010 7:31 AM

Answers

  • I assume that when you get the error, one of the two macros named CheckIt or UncheckIt is highlighted in the VBA editor. The most likely reason for that error is that the template you're working with does not contain an AutoText entry named "Checked Box" or "Unchecked Box". (Unfortunately VBA's error handler never specifies which collection it's complaining about, but in this case the AutoTextEntries collection is the only one involved in the code.) Greg's steps 3 and 4 are written for Word 2003 or earlier, and they need some additional information for Word 2007 or 2010.

    In Word 2007 or 2010, AutoText has become part of the larger Building Blocks feature. You should have noticed that the dialog you get when you press F3 is different from the one shown on Greg's page; now it's a Create New Building Block dialog with more boxes. To get an AutoText entry, you MUST change the Gallery box from "Quick Parts" to "AutoText". Also, to make the AttachedTemplate part of the code work, you MUST change the Save In box from Building Block.dotx to the name of the template that contains the code.

    One other bit: Don't save the code into a .docm document, because that will lose the AutoText entries (which can only be stored in templates, not in documents).

    Woodabyna wrote:

    I have followed Greg's instructions for check boxes on
    http://gregmaxey.mvps.org/Add_Toggle_Objects.htm but when I double
    click on the box it gives me the run time error. I have saved as a
    template (.dotm) and then saved document as a .docm but always get
    the same error. Would love this to work as I can not have both
    controls and legacy form controls in same document - good on you
    microsoft!

    Any help would be great.


    Jay Freedman MS Word MVP
    • Marked as answer by Bessie Zhao Tuesday, July 13, 2010 2:18 AM
    Wednesday, July 07, 2010 2:10 PM

All replies

  • Try with the Toggle Objects.zip file that you can download from Greg's site.

    -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "Woodabyna" wrote in message news:8ffb33d5-a876-49c2-aaf3-22c02257c903@communitybridge.codeplex.com...

    I have followed Greg's instructions for check boxes on http://gregmaxey.mvps.org/Add_Toggle_Objects.htm but when I double click on the box it gives me the run time error. I have saved as a template (.dotm) and then saved document as a .docm but always get the same error. Would love this to work as I can not have both controls and legacy form controls in same document - good on you microsoft!

    Any help would be great.


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    Wednesday, July 07, 2010 9:14 AM
  • I assume that when you get the error, one of the two macros named CheckIt or UncheckIt is highlighted in the VBA editor. The most likely reason for that error is that the template you're working with does not contain an AutoText entry named "Checked Box" or "Unchecked Box". (Unfortunately VBA's error handler never specifies which collection it's complaining about, but in this case the AutoTextEntries collection is the only one involved in the code.) Greg's steps 3 and 4 are written for Word 2003 or earlier, and they need some additional information for Word 2007 or 2010.

    In Word 2007 or 2010, AutoText has become part of the larger Building Blocks feature. You should have noticed that the dialog you get when you press F3 is different from the one shown on Greg's page; now it's a Create New Building Block dialog with more boxes. To get an AutoText entry, you MUST change the Gallery box from "Quick Parts" to "AutoText". Also, to make the AttachedTemplate part of the code work, you MUST change the Save In box from Building Block.dotx to the name of the template that contains the code.

    One other bit: Don't save the code into a .docm document, because that will lose the AutoText entries (which can only be stored in templates, not in documents).

    Woodabyna wrote:

    I have followed Greg's instructions for check boxes on
    http://gregmaxey.mvps.org/Add_Toggle_Objects.htm but when I double
    click on the box it gives me the run time error. I have saved as a
    template (.dotm) and then saved document as a .docm but always get
    the same error. Would love this to work as I can not have both
    controls and legacy form controls in same document - good on you
    microsoft!

    Any help would be great.


    Jay Freedman MS Word MVP
    • Marked as answer by Bessie Zhao Tuesday, July 13, 2010 2:18 AM
    Wednesday, July 07, 2010 2:10 PM
  • Jay,

    (Word 2007)

    I found this response because I received the same error. I am trying to simply create a series of macros that assistants can use to insert a signature building block into a document. My original plan was to use a global template (located in the Workgroup location.) With Word 2007 I have to save my macros in a .dotm and my building blocks (auto text) in a .dotx file. So, does this mean I have to store the two separate templates - .dotm for the macros and .dotx for the building blocks in the Workgroup directory, and hope that no one deletes/moves/etc.. one of them?

    Seems that I would have to load both in order for the macro to "find" the Building Block/AutoText signature.

    Any suggestions are greatly appreciated.

    Thanks,


    Wednesday, December 29, 2010 7:33 PM
  • Hi jstouse

    <<My original plan was to use a global template (located in the Workgroup location.) With Word 2007 I have to save my macros in a .dotm and my building blocks (auto text) in a .dotx file.>>

    You can store AutoText or Building Blocks in a *.dotm file.


    Cindy Meister, VSTO/Word MVP
    Thursday, December 30, 2010 7:32 AM