Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Nov 2002
    Posts
    387
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Removing an xla addin via VBA code (Excel 2000)

    How does one via VBA code remove, delete, the xla from the addins dialog list. I know that setting the addin Install property to false unchecks it but I need to totally remove the addin via code. I have tried recoding a macro of this procedure while deleting one in the Addins dialog list but it doesn't record it.

  2. #2
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Removing an xla addin via VBA code (Excel 2000

    It appears that on loading, Excel will show the following as available Add-Ins:<UL><LI>The Registry Values for Microsoft Add-Ins (HKLMSOFTWAREClassesInstallerComponentsC848331AADA A4D11298D0001A58916F6 on my loaded Excel 2003);<LI>Anything in the default Add-Ins folder which has been saved as an Add-In - whether or not it has the XLA extension;<LI>Parsed values listed under HKCUSoftwareMicrosoftOffice[Version Number]ExcelAdd-in Manager.[/list]To complete the picture, loaded Add-Ins are listed as REG_SZ (String Value) keys under HKCUSoftwareMicrosoftOffice[Version Number]ExcelOptions - with the names OPEN, OPEN1 etc.

    This has not been tested on Office 2000. The third item, however, may well be where the "caching" you were referring to in <post#=328398>post 328398</post#> comes from.

    If this is the case for your set-up, then deleting the String Value from the Registry in code, using a reference to the Scripting Runtime Library, would appear to be your solution. Provide, of course, that you are loading your Add-In from somewhere other than the default Add-Ins folder. The Scripting Runtime reference will enable you to access the Registry Commands available to the Windows Scripting Host. I'm not sure whether the Word Class Module attached to <!post=this post,272243>this post<!/post> will be of help to you, but it may give you some inspiration.

    HTH
    Gre

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Removing an xla addin via VBA code (Excel 2000)

    Wouldn't this suffice:

    Dim sFile as string
    sFile=Workbooks("YourAddin.xla").Fullname
    Workbooks("YourAddin.xla").Close False
    Kill sFile
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  4. #4
    3 Star Lounger
    Join Date
    Nov 2002
    Posts
    387
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Removing an xla addin via VBA code (Excel 2000)

    No, I have tried that. This problem has become very strange and arises because of the following:

    1) Orinigally the xla was placed into the standard startup folder location under the user's document Settings path so that it would get loaded upon startup of Excel
    2) Due to requirements we really needed the addin not to be auot loaded but rather loaded on demand so the addin was moved to a non startup folder.
    3) We do have a COM addin that is always loaded and via a Workbook open or new event we first check to see if the addin in question has been loaded from a previous Excel instance. If this is the first instance of Excel then we attempt to add it to the addin's collection via Addins.Add method, which causes and error that the "Add" method cannot be found, which makes no sense.

    I am wondering if the Add method is not working for one or both of the following reasons:

    1) The Excel instance is not visible
    2) Since the Addin is still in the Addin's list it cannot add a dupicate which is why I was looking for a way to remove the old one from the list of addins that appears in the addins dialog.

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Removing an xla addin via VBA code (Excel 2000)

    I guess it would be simplest if you do not "install" the addin where it is needed, but simply open it like you would with a normal workbook.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  6. #6
    3 Star Lounger
    Join Date
    Nov 2002
    Posts
    387
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Removing an xla addin via VBA code (Excel 2000)

    But then it does not behave as an addin but rather as a seperate instance. The addin we are using has functions in it that respond to specific actions on one of our workbooks.

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Removing an xla addin via VBA code (Excel 2000)

    <hr>But then it does not behave as an addin but rather as a seperate instance. The addin we are using has functions in it that respond to specific actions on one of our workbooks.<hr>
    Are you saying that using the method I described the addin is opened in a separate *instance* of Excel? If so, your code is wrong somehow. You should be able to open a workbook in the current session of Excel. If the workbook has a Workbook_Open event that properly initialises its events, it should work as expected, be it an addin or not.

    It makes NO difference whether an addin is loaded because it is installed, because it is in XLSTART or by code opening it as a normal workbook. The ONLY difference in how an addin is treated is that when one INSTALLS it, the "Private Sub Workbook_AddinInstall()" event is fired. Likewise at uninstall the event "Private Sub Workbook_AddinUninstall()" fires. All other methods fire the workbook_Open event.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

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