Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Working Copy of Excel Template... 2

Status
Not open for further replies.

MeisoT

Technical User
Apr 25, 2004
43
US
I need to open a working copy (.xls) of an Excel Template (.xlt). Using the RunApp command in a macro opens the actual template file, but not a working .xls copy.

I've seen previous posts for this topic, but no suitable answer. Anyone have any idea how to do this?

Thanks,
EJ
 
Thanks crobg, but I forgot to mention that I am opening the template from within Access using a macro - not from within Excel. How can I open it from Access?
 
I thought you might want to do this from Access but I wasn't sure. :)

Make sure you have Microsoft Excel checked in your reference list. (From a module, go to menu Tools->References.)
Code:
Dim xl As New Excel.Application

Set xl = CreateObject("Excel.Application")
xl.Visible = True
xl.workbooks.Add "c:\test.xlt"
 
I'm sorry, that last post is for a module not a macro. This is the easiest way I know to do what you are looking for. Copy the following code into a module and then you can call it from any event in Access. Including a Macro by using RunCode command.

Code:
Function OpenTemplate()
Dim xl As New Excel.Application

Set xl = CreateObject("Excel.Application")
xl.Visible = True
xl.workbooks.Add "c:\test.xlt"
End Function
 
crobg, you are a genius. It works great!!! I've seen other posts with the same question but this is the first correct response I've seen. Thanks a million!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top