Het onderstaande vb-script draagt zorgt voor de installatie van een op te geven Excel AddIn. Wanneer de AddIn reeds aanwezig is zal deze eerst verwijderd worden, alvorens de nieuwe wordt geinstalleerd.
Dim objExcel
Dim objFSO
Dim excelAddIn
Dim startupPath
excelAddIn = "AddIn.xlam"
set objExcel = Nothing
On Error Resume Next
Set objExcel = GetObject(, "Excel.Application")
On Error GoTo 0
If Not objExcel Is Nothing Then
WScript.Echo "Sluit Excel en probeer opnieuw!"
Else
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
startupPath = objExcel.startupPath & "\"
If objFSO.FileExists(startupPath & excelAddIn) Then
objFSO.DeleteFile startupPath & excelAddIn
MsgBox "Oud bestand verwijderd.", vbInformation, "Deinstallatie succesvol"
End If
objFSO.CopyFile excelAddIn, startupPath & excelAddIn
MsgBox "Nieuw bestand gekopieerd naar opstartdirectory van Excel.", vbInformation, "Installatie succesvol"
End If
