Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
drag down Tami Excel Worksheet Functions 6 September 20th 09 04:49 PM
how do i drag a formula sanger Excel Worksheet Functions 4 November 26th 08 05:38 AM
How to use VBA to drag down vumian[_11_] Excel Programming 2 July 19th 06 08:40 PM
drag..... Ankur Excel Discussion (Misc queries) 2 August 22nd 05 09:25 AM
Excel 2000/XP script to Excel97 script hat Excel Programming 3 March 2nd 04 03:56 PM


All times are GMT +1. The time now is 01:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"