PC Review


Reply
Thread Tools Rate Thread

Drag-n-Drop_XLA_Install (VB Script)

 
 
Mark Ivey
Guest
Posts: n/a
 
      30th Dec 2007
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
my drag arrow does not appear so cant drag pics etc. =?Utf-8?B?YXdyaXRl?= Microsoft Word Document Management 0 31st May 2005 11:53 PM
RE: my drag arrow does not appear so cant drag pics etc. =?Utf-8?B?Q3liZXJUYXo=?= Microsoft Word Document Management 0 31st May 2005 11:41 PM
BUG: Script blocking strips script parameters during script authorization Jonathan K. Shay Spyware Announcements 3 2nd May 2005 06:18 PM
Track tree node during drag operation? MouseMove doesn't fire during drag?? Samuel R. Neff Microsoft VB .NET 3 30th Dec 2004 02:13 AM
Track tree node during drag operation? MouseMove doesn't fire during drag?? Samuel R. Neff Microsoft VB .NET 0 23rd Dec 2004 04:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:04 PM.