• OnAction oddity (2003)

    Author
    Topic
    #433214

    I am confused once again.
    I have a toolbar which calls various subroutines in an add-in. One of the buttons works are expected. The other 5 do not work at all. They report “The macro .. could not be found.” All the macros are in the same module in an add-in. When the Isaddin? property is false on the xla, everything works fine. Set it to true an only one button works. The OnAction string is the same except for the last few characters define the macro.

    Any ideas?

    For this application, I can live IsAddIn? being false. However, I hate to be this close and having to settle.

    Viewing 0 reply threads
    Author
    Replies
    • #1018458

      hello There

      Try and explicitly point to the code so that the button can find it.

      Workbook name | Module Name | Proc Name…

      Are you passing any arguments or variables to these, that can also do it…

      Tell us if you need more help.

      Wassim

      • #1018467

        The OnAction string contains the complete filepath/filename/macro. Similar to the following (The only difference being the text after the _)
        ‘C:Documents and SettingsAll UsersDocumentsCBBTAnnualInspection.xla’!Inspect_Bent

        There are no arguments to the subs. The subs are explicitly listed as public.

        Interrestingly, the macros that do not work, also do not run from the Tools-> macro. While the one that does work can be accessed in that manor.

        • #1018487

          hello gibbindr

          You said << macro. While the one that does work can be accessed in that manor. >>>

          I think these ones that don’t work may have an argument or a variable passed to them, and this is one reason why they don’t show up in the Macros window.

          Did you try to Call these ones that don’t work: Call Proc name from a sub?

          Try and look to see if the path is not being truncated some where along the way. Possibly change the _ to nothing and test one and see what is going on. Possibly the path is getting too long for the system to handle, and then you have this thing happen. Try and isolate the path that is working, and then see how many characters it has, and make the other than same number.

          These are all suggestions, and they are free.

          Cordially

          Wassim

        • #1018489

          Try assigning just the macro name, without the name and path of the add-in:

          Application.CommandBars(“My Toolbar”).Controls(1).OnAction = “Inspect_Bent”

          or

          Application.CommandBars(“My Toolbar”).Controls(“My Button”).OnAction = “Inspect_Bent”

          It’s strange that one of the macros in the add-in is visible in Tools | Macro | Macros… Are you sure this is not a macro of the same name in another workbook (for example in your Personal.xls)?

          • #1018675

            “Are you sure this is not a macro of the same name in another workbook ”
            Very close to the actual problem.

            Although the macros did not exist in other open workbooks, they did at one time. And that seems to be the problem.
            I copied the worksheets to a new book, copied the one module (has _Open code) into the same new book. Closed the original file and everything now works.

            Thanks for the ideas. They gave me some ideas on what was really going on.

    Viewing 0 reply threads
    Reply To: Reply #1018467 in OnAction oddity (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel