Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default VBS script to start Excel and load Add-ins

Hi,

A few weeks ago a posting of mine contained a request for a script to start
excel, load add-ins and open the wb given by the first agrument to the
script. keepITcool was kind enough to answer with essentially the following:

Dim XL
Dim agrs
Dim ai

on error resume next
set XL = GetObject(,"Excel.Application")

If XL is Nothing Then

Set XL = CreateObject("Excel.Application")

For Each ai In xL.AddIns
If ai.Installed Then
XL.Workbooks.Open(ai.FullName).RunAutoMacros 1
End If
Next
End If

XL.Workbooks.Open WScript.Arguments(0)
XL.Visible = True
---------------------------------------------------

This script causes 2 problems for me:
1. Add-ins are not opened in the order specified by the registry, but rather
alphabetically. Since one of my add-ins depends on the other, this doesn't
work for me.
2. It fails to open the MS addin "MSN Equity Quotes" complaining that it is
the wrong format.

Any way to modify the script to make it work in these cases?

Many thanks in advance.

Aaron Fude


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default VBS script to start Excel and load Add-ins

i dont know about the MSN addin.. but the rest:


if your addins are "load order" dependent, i suggest you change their
"title" properties so they always load in the correct order

else change the script like

For Each ai In xL.AddIns
If lcase(ai.Name) = "myfirst.xla" Then
XL.Workbooks.Open(ai.FullName).RunAutoMacros 1
End If
Next
For Each ai In xL.AddIns
If lcase(ai.Name) = "mysecond.xla" Then
XL.Workbooks.Open(ai.FullName).RunAutoMacros 1
End If
Next
'in case you need the other addins...
For Each ai In xL.AddIns
if ai.installed then
if lcase(ai.name) < "myfirst.xla" _
and lcase(ai.name) < "mysecond.xla" then
XL.Workbooks.Open(ai.FullName).RunAutoMacros 1
End If
end if
Next



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Aaron Fude" wrote:

Hi,

A few weeks ago a posting of mine contained a request for a script to
start excel, load add-ins and open the wb given by the first agrument
to the script. keepITcool was kind enough to answer with essentially
the following:

Dim XL
Dim agrs
Dim ai

on error resume next
set XL = GetObject(,"Excel.Application")

If XL is Nothing Then

Set XL = CreateObject("Excel.Application")

For Each ai In xL.AddIns
If ai.Installed Then
XL.Workbooks.Open(ai.FullName).RunAutoMacros 1
End If
Next
End If

XL.Workbooks.Open WScript.Arguments(0)
XL.Visible = True
---------------------------------------------------

This script causes 2 problems for me:
1. Add-ins are not opened in the order specified by the registry, but
rather alphabetically. Since one of my add-ins depends on the other,
this doesn't work for me.
2. It fails to open the MS addin "MSN Equity Quotes" complaining that
it is the wrong format.

Any way to modify the script to make it work in these cases?

Many thanks in advance.

Aaron Fude




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
Script to start Excel and load the add-ins Aaron Fude Excel Programming 3 October 21st 04 09:08 PM
Load Macro at start up? No Name Excel Programming 1 October 28th 03 07:27 PM
Load Macro at start up? MJ Antoszkiw Excel Programming 0 October 21st 03 04:11 PM
Load Macro at start up? Tom Ogilvy Excel Programming 0 October 21st 03 03:49 PM
Load Macro at start up? Frank Isaacs Excel Programming 0 October 21st 03 03:47 PM


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

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"