How to load Excel startup files through code

  • Thread starter Thread starter e'kong.tse
  • Start date Start date
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
 
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
 
Back
Top