Weird AddIn behaviour
Hi Trefor,
The behaviour you described is predictable, it's the behaviour Addins
collection that's weird!.
When you uninstalled addin-1 you didn't remove it from the Addins
collection. When you tried to addin-2 with the same title (in absence of a
title it defaults to name) it simply reinstalled the similarly 'titled'
addin that already exists in the addins collection, ie addin-1.
Possible solutions -
1 - remove addin-1 from the collection.
1a) Manually, after uninstalling the addin remove it from the current
folder. Try & re-check it in Tools Addins. Follow the prompts to allow
removal.
Note - If the addin is not in one of the default addins locations need to do
this in same session as it was uninstalled. Otherwise in next session it
won't be visible in the drop down (but it still exists in the registry)
1b) Remove from the registry if it's not in a default location (manually or
programmatically). If it's in a default addins location and uninstalled it
won't be in the registry, so after uninstalling move it to another folder
2 Give addin-2 a unique title
Load it from file
wb.title = "new title"
wb.save
Now you should be able to install addin-2
Also note if your addins had same titles but different names located in
different folders the same scenario you described would occur.
Regards,
Peter T
PS, you didn't need to go to the trouble of modifying code in respective
addins to demonstrate. Select the file in Project Explorer (ctrl-R) and in
the intermediate window
?thisworkbook.fullname
hit enter
"Trefor" wrote in message
...
I seem to have this really weird problem and I am not sure how to fix. Let
me explain via an example:
1. Open a new workbook.
2. Open VBE and create a new module
3. In the module simply type a comment: ' This is file 1
4. Save As Add-In c:\test.xla
5. In the module edit the line to read: ' This is file 2
6. Save As Add-In c:\temp\test.xla <<__ Must be same filename but
different
directory
7. In any module:
With AddIns.Add(Filename:="c:\test.xla")
.Installed = True
End With
Edit the module and confirm the comment : ' This is file 1
With AddIns.Add(Filename:="c:\test.xla")
.Installed = False
End With
With AddIns.Add(Filename:="c:\temp\test.xla")
.Installed = True
End With
8. Edit the module and confirm the comment IT IS STILL: ' This is file 1
i.e. the original file!
9. Close the file and exit from Excel, then double click on
"c:\temp\test.xla" and I get an error message saying the file is already
open.
10. Excel Tools Add-Ins and uncheck test and exit excel
With AddIns.Add(Filename:=" c:\temp\test.xla")
.Installed = True
End With
11. Edit the module and confirm the comment IT IS STILL: ' This is file 1
i.e. the original file!
12. Excel Tools Add-Ins and uncheck test and exit excel
13. From explorer double-click on "c:\temp\test.xla"
14. Edit the module and confirm the comment: ' This is file 2
In summary, once a file has been opened from a particular location, even
if
you:
With AddIns.Add(Filename:="c:\temp\test.xla")
.Installed = False
End With
Any attempt to load the file from another location using AddIns.Add simply
opens the file from the original path.
In VBA code how can I "update" to add the Add-In the new location?
--
Trefor
|