Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Drag-n-Drop_XLA_Install (VB Script)
If anyone is interested, I played around with the code and created a VB
Script file that will install an Excel addin. Here is how it works. Take the code below and save it to a ".vbs" file (what ever filename you see fit to use). Save this file somewhere convenient (like your desktop). Now you can take an addin file (".xla" type) and drag-n-drop it onto this VB Script file and it will install the addin for you. Please feel free to make improvements to this script and let me know of any problems. I am totally open to ideas for any improvements. I have not included any error correction/monitors to this code, but feel free to improve on it and re-post your ideas/thoughts. VB Script Code (watch for word wrap issues): '_________________________________________________ ___________________ Dim fso, myAddinFile myAddinFile = WScript.arguments.item(0) Set fso = CreateObject("Scripting.FileSystemObject") myAddinFileName = fso.GetFileName(myAddinFile) myAddinPath = fso.GetAbsolutepathname(myAddinFile) sProcessName = "EXCEL.exe" sComputer = "." Set oWmi = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2") Set oShell = CreateObject("WScript.Shell") Do Set colProcessList = oWmi.ExecQuery _ ("Select * from Win32_Process Where Name = '" & sProcessName & "'") If colProcessList.Count = 0 Then ' process is not running Dim oXL Dim oAddin Set oXL = CreateObject("Excel.Application") oXL.Workbooks.Add Set oAddin = oXL.AddIns.Add(myAddinPath, True) oAddin.Installed = True oXL.Quit Set oXL = Nothing MsgBox myAddinFileName & " was successfully installed.", vbOKOnly, "Addin Installation OK" Exit Do ElseIf colProcessList.Count < 0 Then ' process is running MsgBox "Excel is currently open. Please close Excel and try again.", vbOKOnly, "MS Excel Is Open" Exit Do End If Loop |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
drag down | Excel Worksheet Functions | |||
how do i drag a formula | Excel Worksheet Functions | |||
How to use VBA to drag down | Excel Programming | |||
drag..... | Excel Discussion (Misc queries) | |||
Excel 2000/XP script to Excel97 script | Excel Programming |