pleeseemailme
Board Regular
- Joined
- Dec 26, 2013
- Messages
- 201
Howdy,
I've spent the past few days researching this and I can't figure out why my code is crashing. I have an add-in I've made that I want to distribute to other co-workers. I've placed the add-in on the network and in the workbook open event I have some code to install the add-in. The code is:
The code could crash at the first line - unable to get the Add property of the AddIns class. I tried modifying the code to this:
Same thing. However, running it this way, when I open the network add-in again, it works. In other words: the first time it crashes, the second time it works.
My guess is what is happening is this: because the add-in isn't in the Library Path when Excel is opened, its not able to add the add-in to the collection. This is why when my second code runs the second time, it works - because the application recognizes an add-in file in the Library Path.
From all my reading online about this subject, this should not be the case. Using the first code should add the add-in to the collection.
So, does anyone have any thoughts on how to fix, or work around this problem? Any help would be greatly appreciated.
I've spent the past few days researching this and I can't figure out why my code is crashing. I have an add-in I've made that I want to distribute to other co-workers. I've placed the add-in on the network and in the workbook open event I have some code to install the add-in. The code is:
Code:
Dim NewAi as AddIn
Set NewAi = _Application.AddIns.Add("filepath" & ThisWorkbook.Name, CopyFile:=True)
NewAi.Installed = True
The code could crash at the first line - unable to get the Add property of the AddIns class. I tried modifying the code to this:
Code:
Application.DisplayAlerts = False
ThisWorkbook.SaveAs Application.UserLibraryPath & ThisWorkbook.Name, xlOpenXMLAddIn
Application.DisplayAlerts = True
Set NewAi = _
Application.AddIns.Add(Application.UserLibraryPath & ThisWorkbook.Name)
NewAi.Installed = True
Same thing. However, running it this way, when I open the network add-in again, it works. In other words: the first time it crashes, the second time it works.
My guess is what is happening is this: because the add-in isn't in the Library Path when Excel is opened, its not able to add the add-in to the collection. This is why when my second code runs the second time, it works - because the application recognizes an add-in file in the Library Path.
From all my reading online about this subject, this should not be the case. Using the first code should add the add-in to the collection.
So, does anyone have any thoughts on how to fix, or work around this problem? Any help would be greatly appreciated.