none
Problem using AddIns.Installed RRS feed

  • Question

  • Hi


    I am in the process of developing a custom tab for the Excel ribbon (2007 and 2010) as an add-in (using Custom UI Editor). However, as I am sure most of you are aware, debugging an Excel add-in can be a real pain because of the process you must go to to remove the add-in and then re-add the add-in to the ribbon.


    As a result, I have added a button to my tab that uninstalls the add-in, so as to save myself some time whilst I am in the process of debugging. This button works perfectly. So I decided to make another add-in with a reinstall button that would complement this tab in the following way:


     - When I click on the reinstall button, my custom tab is installed and then my reinstall tab is uninstalled (in that order)
     - When I click on the uninstall button on the custom tab, my reinstall tab is installed and then my custom tab is uninstalled (again, in that order)


    The uninstall button still works perfectly on my custom tab. But when I click on the reinstall button on my second add-in, I get a prompt saying "Cannot run the macro ''Reinstall Adam''s Add-Ins.xlam'!Auto_Remove'. The macro may not be available in this workbook or all the macros may be disabled." but yet the custom tab still installs as it should. (Btw, I would be satisfied if I could stop the error coming up with an

    On Error Resume Next

    but that doesn't work).


    The uninstall function looks like this (called from the custom tab):

    Sub UninstallTab(control As IRibbonControl)
        On Error Resume Next
            AddIns("Reinstall Adam's Add-Ins").Installed = True
            AddIns("Adam's Add-Ins").Installed = False
        On Error GoTo 0
    End Sub

    And the reinstall function looks like this (called from the second add-in, which is also in its own ribbon developed with Custom UI Editor):

    Sub ReinstallTab(control As IRibbonControl)
        On Error Resume Next
            AddIns("Adam's Add-Ins").Installed = True
            AddIns("Reinstall Adam's Add-Ins").Installed = False
        On Error GoTo 0
    End Sub

    I have also tried changing the above pieces of code so that neither of the two add-ins is attempting to uninstall itself. In this case I have put the

    AddIns.Installed = False

    in the

    Workbook_AddinInstall()

    section of the other add-in (i.e. the custom tab uninstalls the reinstall tab when it is installed, and the reinstall tab uninstalls the custom tab when it is installed). The error message is almost the same, just with ''Adam''s Add-Ins'!Auto_Add' instead of ''Reinstall Adam''s Add-Ins'!Auto_Remove'.



    Please also note that everything works well if I don't attempt to uninstall the "Reinstall" tab, but I figured that there shouldn't be a problem with doing so because I can do it from the custom tab.


    Can someone please help me out with this, I have been working on this for 3 days now and I am getting really frustrated, and something that was supposed to be making my life easier is actually having the opposite effect.


    Thanks

    Wednesday, February 8, 2012 9:55 PM

Answers

  • [From your OP] However, as I am sure most of you are aware, debugging an Excel add-in can be a real pain because of the process you must go to remove the add-in and then re-add the add-in to the ribbon.

    No I am not aware of that at all!

    I can't think of any reason you need to add/remove an addin from the addins collection for debugging purposes, other perhaps than anything directly related to the addin needing to be actually "installed", rather than merely loaded. Adding the addin to the collection is not related to anything that goes on in the ribbon, except as a by-product that can un/load the workbook.

    When I'm developing an addin I (almost) never add it to the addins collection, yet alone install it (ie ticked in the addins manager). There's no need, simply load it as a normal workbook. For convenience maybe have code in some other addin or personal to do -
    workbooks.open("myaddin.xlam") and similar to close it

    FWIW I only have only a very small number of addins installed, one is an addin to un/load (but not install) other addins from a simple UI.

    In passing, to avoid those silly messages include the following in a normal module

    Sub auto_add()
    End Sub
    Sub auto_remove()
    End Sub

    They were the equivalent of auto_open/close and superseded with equivalent workbook events, though occasionally get called when and addin is un/installed. Not quite sure why their not being found prompts the message but it seems to be a timing thing which only manifests in relatively rare scenarios.

    Peter Thornton

    • Marked as answer by ajryan88 Thursday, February 9, 2012 9:14 PM
    Thursday, February 9, 2012 9:39 AM
    Moderator

All replies

  • hi ajryan88,
     
    i don't understand when you said "my second add-in" can you explain more
     --
    isabelle
     
    Le 2012-02-08 16:55, ajryan88 a écrit :
    > Hi
    >
    >
    > I am in the process of developing a custom tab for the Excel ribbon (2007 and 2010) as an add-in (using Custom UI Editor). However, as I am sure most of you are aware, debugging an Excel add-in can be a real pain because of the process you must go to to remove the add-in and then re-add the add-in to the ribbon.
    >
    >
    > As a result, I have added a button to my tab that uninstalls the add-in, so as to save myself some time whilst I am in the process of debugging. This button works perfectly. So I decided to make another add-in with a reinstall button that would complement this tab in the following way:
    >
    >
    > - When I click on the reinstall button, my custom tab is installed and then my reinstall tab is uninstalled (in that order)
    > - When I click on the uninstall button on the custom tab, my reinstall tab is installed and then my custom tab is uninstalled (again, in that order)
    >
    >
    > The uninstall button still works perfectly on my custom tab. But when I click on the reinstall button on my second add-in, I get a prompt saying "Cannot run the macro ''Reinstall Adam''s Add-Ins.xlam'!Auto_Remove'. The macro may not be available in this workbook or all the macros may be disabled." but yet the custom tab still installs as it should. (Btw, I would be satisfied if I could stop the error coming up with an
    >
    > On Error Resume Next
    >
    > but that doesn't work).
    >
    >
    > The uninstall function looks like this (called from the custom tab):
    >
    > Sub UninstallTab(control As IRibbonControl)
    >      On Error Resume Next
    >          AddIns("Reinstall Adam's Add-Ins").Installed = True
    >          AddIns("Adam's Add-Ins").Installed = False
    >      On Error GoTo 0
    > End Sub
    >
    > And the reinstall function looks like this (called from the second add-in, which is also in its own ribbon developed with Custom UI Editor):
    >
    > Sub ReinstallTab(control As IRibbonControl)
    >      On Error Resume Next
    >          AddIns("Adam's Add-Ins").Installed = True
    >          AddIns("Reinstall Adam's Add-Ins").Installed = False
    >      On Error GoTo 0
    > End Sub
    >
    > I have also tried changing the above pieces of code so that neither of the two add-ins is attempting to uninstall itself. In this case I have put the
    >
    > AddIns.Installed = False
    >
    > in the
    >
    > Workbook_AddinInstall()
    >
    > section of the other add-in (i.e. the custom tab uninstalls the reinstall tab when it is installed, and the reinstall tab uninstalls the custom tab when it is installed). The error message is almost the same, just with ''Adam''s Add-Ins'!Auto_Add' instead of ''Reinstall Adam''s Add-Ins'!Auto_Remove'.
    >
    >
    >
    > Please also note that everything works well if I don't attempt to uninstall the "Reinstall" tab, but I figured that there shouldn't be a problem with doing so because I can do it from the custom tab.
    >
    >
    > Can someone please help me out with this, I have been working on this for 3 days now and I am getting really frustrated, and something that was supposed to be making my life easier is actually having the opposite effect.
    >
    >
    > Thanks
    >
     
    Thursday, February 9, 2012 4:34 AM
  • My second add-in is the one with the reinstall button...
    Thursday, February 9, 2012 4:57 AM
  • it seem you use the same object to do create and remove object ,
    or sorry maybe i'm out of track, can you give us a file exemple
     
    --
    isabelle
     
    Le 2012-02-08 23:57, ajryan88 a écrit :
    > My second add-in is the one with the reinstall button...
     
    Thursday, February 9, 2012 5:45 AM
  • Here is a link to two files that I just created which cause the same problem as described above:

    http://ajryan88.byethost3.com/Uninstall.xlam

    http://ajryan88.byethost3.com/Reinstall.xlam

    To make this work as intended, you need to make sure you add the "Uninstall" add-in to the Add-Ins list first, but make sure you UNCHECK it so that it is not installed when you click OK. Then, before you click OK, you need to add the "Reinstall" add-in, this time leaving the box checked so that the add-in is installed properly.

    Once installed, you will see a tab titled "Reinstall". There is only a single button in there, titled "Install Custom Tab". This is the button that is causing all of the error message. As described above, the custom tab is still installing properly despite the error message. Once the "Custom Tab" is installed into its own tab (the "Reinstall" tab has now been removed from the ribbon), you will see a single button in there, title "Uninstall Custom Tab". Clicking on this button also produces an error message analagous to the previous error message, but everything still functions exactly as it is supposed to.

    I hope this helps you help me.

    Thanks,

    - Adam



    • Edited by ajryan88 Thursday, February 9, 2012 7:07 AM Formatting error upon insertion of links
    Thursday, February 9, 2012 7:05 AM
  • [From your OP] However, as I am sure most of you are aware, debugging an Excel add-in can be a real pain because of the process you must go to remove the add-in and then re-add the add-in to the ribbon.

    No I am not aware of that at all!

    I can't think of any reason you need to add/remove an addin from the addins collection for debugging purposes, other perhaps than anything directly related to the addin needing to be actually "installed", rather than merely loaded. Adding the addin to the collection is not related to anything that goes on in the ribbon, except as a by-product that can un/load the workbook.

    When I'm developing an addin I (almost) never add it to the addins collection, yet alone install it (ie ticked in the addins manager). There's no need, simply load it as a normal workbook. For convenience maybe have code in some other addin or personal to do -
    workbooks.open("myaddin.xlam") and similar to close it

    FWIW I only have only a very small number of addins installed, one is an addin to un/load (but not install) other addins from a simple UI.

    In passing, to avoid those silly messages include the following in a normal module

    Sub auto_add()
    End Sub
    Sub auto_remove()
    End Sub

    They were the equivalent of auto_open/close and superseded with equivalent workbook events, though occasionally get called when and addin is un/installed. Not quite sure why their not being found prompts the message but it seems to be a timing thing which only manifests in relatively rare scenarios.

    Peter Thornton

    • Marked as answer by ajryan88 Thursday, February 9, 2012 9:14 PM
    Thursday, February 9, 2012 9:39 AM
    Moderator
  • Thanks very much for your help Peter, you have solved all of my problems.

    Btw, I understand that an experienced developer may not see the need to constantly uninstall/install and add-in whenever they make changes because they probably get it right first time every time, but I myself, as an inexperienced add-in developer, do see the appeal of being able to install/uninstall an add-in at the single click of a button, rather than having to go through the Office menu every time.

    Thanks again Peter,

    - Adam

    Thursday, February 9, 2012 9:18 PM
  • Btw, I understand that an experienced developer may not ... whenever they
    make changes because they probably get it right first time every time,

    Ah, if only that were true :-)

    do see the appeal of being able to install/uninstall an add-in at the
    single click of a button, rather than having to go through the Office menu
    every time

    If you mean the method to un/install an addin via the Excel menu system, I agree, it's convoluted to say the least. However to load an addin for development (or even regular use) is no different to loading any other normal workbook, eg File open, click from file, recent files, code Workbooks.Open("path/myaddin.xlam"), etc.

    Indeed there's no UI or button to unload an addin (which is why I made my own), though fwiw one way is select the project in VBE, and in the Immediate window (ctrl-G) do
     thisworkbook.close
    and hit enter.

    Peter Thornton

    Friday, February 10, 2012 3:18 PM
    Moderator