devilishblueyes
New Member
- Joined
- Oct 18, 2007
- Messages
- 18
I'm trying to make my VBA addins simpler to install for my co-workers so that they can install and update them to their computer with basically just the click of a button. I have been able to get the code to work fine for my computer and another co-worker's computer. But when I tried to install it on a 2nd worker's computer it keeps failing when I try setting Installed to True. I'm using a .XLSM file on a shared server that has a command button on it that when it is clicked does the following:
1. Determines if there are any old addins with the same name and removes them
Sub rmvAddIn(MyName As String)
If HasAddIn(MyName) = True Then
AddIns(MyName).Installed = False
End If
End Sub
Function HasAddIn(MyName As String) As Boolean
Dim MyAddin As AddIn
Err = 0
On Error Resume Next
Set MyAddin = AddIns(MyName)
If Err = 0 Then HasAddIn = True Else HasAddIn = False
Set MyAddin = Nothing
On Error GoTo 0
End Function
2. Copies the add in files from the server and adds them to the AddIns folder as an Addin
Dim MyName() As String
ReDim MyName(1)
MyName(0) = "MyCalculator"
MyName(1) = "MyEntries"
Call rmvAddIn(MyName(0))
AddIns.Add ThisWorkbook.Path & "\" & MyName(0) & ".xla", True
3. Installs the AddIn
AddIns(MyName(0)).Installed = True
It is the last line where it fails on the one computer, yet it works perfectly fine on my computer and another. I've researched it on the web and can't seem to find an answer anywhere. I'm not having difficulty adding the AddIn. It shows that it has been added and by using the command button in .XLSM file it forces at least one workbook to be open. I've tried different variations of Excel Security settings and that hasn't worked. And I've even tried looping through the AddIn objects like so:
Dim MyObj As AddIn
For Each MyObj IN AddIns
If MyObj.Name Like "MyCalculator*" Then
MyObj.Installed = True
Exit For
End If
Next MyObj
And even that wouldn't work. Even tried with one line:
AddIns.Add(ThisWorkbook.Path & "\" & MyName(0) & ".xla", True).Installed = True
So the AddIn definitely exists when I try to install it. I'm at a total loss about how to tackle it. The only article that made some sense was something someone wrote where they found that in their case it wasn't clearing out the name for their addin in the registry. I normally try to avoid working with the registry since I don't know a lot about it and don't want to majorly screw up the computer.
Please help!
1. Determines if there are any old addins with the same name and removes them
Sub rmvAddIn(MyName As String)
If HasAddIn(MyName) = True Then
AddIns(MyName).Installed = False
End If
End Sub
Function HasAddIn(MyName As String) As Boolean
Dim MyAddin As AddIn
Err = 0
On Error Resume Next
Set MyAddin = AddIns(MyName)
If Err = 0 Then HasAddIn = True Else HasAddIn = False
Set MyAddin = Nothing
On Error GoTo 0
End Function
2. Copies the add in files from the server and adds them to the AddIns folder as an Addin
Dim MyName() As String
ReDim MyName(1)
MyName(0) = "MyCalculator"
MyName(1) = "MyEntries"
Call rmvAddIn(MyName(0))
AddIns.Add ThisWorkbook.Path & "\" & MyName(0) & ".xla", True
3. Installs the AddIn
AddIns(MyName(0)).Installed = True
It is the last line where it fails on the one computer, yet it works perfectly fine on my computer and another. I've researched it on the web and can't seem to find an answer anywhere. I'm not having difficulty adding the AddIn. It shows that it has been added and by using the command button in .XLSM file it forces at least one workbook to be open. I've tried different variations of Excel Security settings and that hasn't worked. And I've even tried looping through the AddIn objects like so:
Dim MyObj As AddIn
For Each MyObj IN AddIns
If MyObj.Name Like "MyCalculator*" Then
MyObj.Installed = True
Exit For
End If
Next MyObj
And even that wouldn't work. Even tried with one line:
AddIns.Add(ThisWorkbook.Path & "\" & MyName(0) & ".xla", True).Installed = True
So the AddIn definitely exists when I try to install it. I'm at a total loss about how to tackle it. The only article that made some sense was something someone wrote where they found that in their case it wasn't clearing out the name for their addin in the registry. I normally try to avoid working with the registry since I don't know a lot about it and don't want to majorly screw up the computer.
Please help!