How to load Excel startup files through code

E

e'kong.tse

Hi,

I'm trying to open up an Excel file (.xls) through code. That file
uses some function located in a Excel Add-in file(.xla). Everything is
fine if I open up that file directly in Excel and the startup file is
specified under Tools->Options->General. However, when I try to open
up the .xls file through code, the add-in file isn't open and so I get
errors in my .xls file. Does anyone know how I can load the startup
files through code?

Thanks!
E'Kong
 
C

Chip Pearson

When you start Excel through code, it doesn't run its startup
procedures, in order to minimize startup time. You'll have to run
startup procedures manually from your code. E.g,

Sub Workbook_Open()
Dim FName As String
Application.AddIns("Analysis ToolPak").Installed = True
FName = Dir(Application.Path & "XLStart\*.xls")
Do Until FName = ""
Workbooks.Open Application.Path & "XLStart\" & FName
FName = Dir()
Loop
FName = Dir(Application.AltStartupPath & "\*.xls")
Do Until FName = ""
Workbooks.Open Application.AltStartupPath & "\" & FName
FName = Dir()
Loop
End Sub

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 

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