I'm using a VBScript to copy an excel addin to a common location on the user's computer (not under the user's profile) and then automatically install the addin in excel. Everything is working great except the command for excel to add the addin file. The problem is with the optional CopyFile argument. The syntax for this call is AddIns.Add (FileName As String, [CopyFile]). If I omit the CopyFile arugument then the script will copy the addin to the correct folder but Excel will make it's own copy under the user's profile, which is not good for a commonly used workplace addin. If I try to specify this parameter then the script crashes.
Ideas, Anyone?
Here is the portion of my script dealing with installing the add-in. All of the sections prior to this point run like a panther. All of the variables have been pre-defined, so don't waste your energy looking for missing variable declarations.
-Joshua
If it's not broken, it doesn't have enough parts yet.
Ideas, Anyone?
Here is the portion of my script dealing with installing the add-in. All of the sections prior to this point run like a panther. All of the variables have been pre-defined, so don't waste your energy looking for missing variable declarations.
Code:
.
.[smooth running code]
.
'Step 5: Install the add-in into microsoft excel
On Error Resume Next
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False
strMsg = xlApp.Name
On Error GoTo 0
If strMsg = vbNullString Then
strMsg = "Unable to locate Microsoft Excel. The add-in file has been copied to the appropriate directly but you will need to add it into excel manually. The add-in file is located in " & strcFolderPath & " (write that file path down!)."
lngButtons = vbExclamation Or vbOKOnly Or vbDefaultButton1 Or vbApplicationModal
MsgBox strMsg, lngButtons, strcScriptTitle
Call KillScript("Cannot Find Excel")
Else
blnAddinReg = False
With xlApp.Application
For F = 1 To .AddIns.Count
If LCase(.AddIns(F).Name) = "lineengineeraddin.xlam" Then
blnAddinReg = True
Exit For
End If
Next
If blnAddinReg = False Then
[highlight].AddIns.Add strAddInPath, False[/highlight]
Else
If .AddIns(F).Installed = False Then
.AddIns(F).Installed = True
End If
End If
End With
End If
strMsg = "Add-in succesfully installed."
lngButtons = vbInformation Or vbOkOnly Or vbDefaultButton1 Or vbApplicationModal
MsgBox strMsg, lngButtons, strcScriptTitle
xlApp.Quit
Call KillScript("Script Finished")
End Sub
Sub KillScript(Reason)
If DebugMode = True And (Not IsNull(Reason)) Then
MsgBox Reason
End If
On Error Resume Next
xlApp.Quit
On Error Goto 0
Set xlApp = Nothing
Set objAddIn = Nothing
Set FSO = Nothing
WScript.Quit
End Sub
-Joshua
If it's not broken, it doesn't have enough parts yet.