Script to start Excel and load the add-ins

A

Aaron Fude

Hi, I have the following script to start Excel if it is not started and to
use an existing instance if it is:

Dim XL
Dim agrs
on error resume next
set XL = GetObject(,"Excel.Application")
If XL is Nothing Then Set XL = CreateObject("Excel.Application")
Set args = WScript.Arguments
XL.Workbooks.Open args(0)
XL.Visible = True

The problem is that if Excel is not started and this starts a new instance,
my add-ins (that are checked) do not load.

How to solve this?

Many thanks in advance,

Aaron Fude
 
K

keepITcool

This should do..

Sub LoadXLwithAddins()
Dim xl As Object
Dim ai As Object

Set xl = CreateObject("Excel.Application")

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

xl.Visible = True
Set xl = Nothing
End Sub


keepITcool

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

Aaron Fude

Hi keepITcool!

Thank you so much for your response. I don't mean to be a brat, but would
you mind combining the two scripts for me. If I do it, I'll mess up
something.

Keeping IT cool,

Aaron
 
K

keepITcool

This?


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


keepITcool

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top