I have a few excel add-ins that fail to load sometimes when I open an existing workbook. Here are some of the pertinent facts and things I have noticed when trying to diagnose:
- These are regular excel add-ins, not COM add-ins.
- Add-ins always load when opening excel from the program menu.
- Add-ins do not load ~10-20% of the time when opening a workbook from email/shared drive/personal drive.
- I am unable to consistently replicate the issue. Sometimes the opening the same workbook will load the add-ins, sometime it won't.
The issue might be connected to one of the toolkits that has an installer built into it. (the idea behind this add-in is that it can be sent to people, and they can install it just by opening. Then, once it's installed in the AddIns folder, it no longer does anything when the add-in is loaded).
Private Sub Workbook_Open() If Right(ThisWorkbook.Path, 6) <> "AddIns" Then Dim blRegister As Boolean Dim ThisAddIn As AddIn Application.DisplayAlerts = False On Error Resume Next ThisWorkbook.Sheets("Installing").Activate Application.AddIns("Toolkit").Installed = False ThisWorkbook.SaveAs "Z:\AppData\Microsoft\AddIns\ToolKit.xlam", AccessMode:=xlExclusive, ConflictResolution:=Excel.XlSaveConflictResolution.xlLocalSessionChanges, FileFormat:=55 On Error GoTo 0 blRegister = Application.RegisterXLL("Z:\AppData\Microsoft\AddIns\ToolKit.xlam") Set ThisAddIn = Application.AddIns.Add("Z:\AppData\Microsoft\AddIns\ToolKit.xlam") ThisAddIn.Installed = True MsgBox "Thanks for Installing the Toolkit!" ThisWorkbook.Close False Application.DisplayAlerts = True End If End Sub
Any help or insight would be greatly appreciated.
AddIns("Toolkit").Namerefers to whenAddIns("Toolkit").IsOpen = True, thenApplication.EnableEvents = False, open the addin afterThisAddIn.Installed = Trueand thenApplication.EnableEvents = TruebeforeThisWorkbook.Close. The thing is, unlessDebug.Printis used on every step, you can't tell where it fails. - PatricK