How to open .xlt in VBA?

G

Guest

Hi,
In VBA, I'm exporting data from Access to Excel and then open the xls. I use
the following code:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, Myqry,
test.xls
Call Shell("Excel.exe test.xls", 1)
So far OK.
Now I want to use a template xlt, so that the user gets a copy xls and
cannot alter the content of the xlt. However,
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, Myqry,
test.xlt
Call Shell("Excel.exe test.xlt", 1)
export OK, but opens directly the xlt in stead of a copy xls. What can I do
to realize the last?

An even better approach would be to first make a copy and then export to and
open that copy. What is the code to make that copy?

Thanks for suggestions,
Henk
 
S

strive4peace

Hi Henk,

FileCopy(Source As String, Destination As String)

make sure you include the filepath in your source and desination

instead of using Shell, you can do this:

application.followhyperlink "c:\path\filename.xls"


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
G

Guest

Hi strive,
I want to open a template, but your code
application.followhyperlink "c:\path\filename.xlt" // (mark xlT)
opens the xlt as such. How can I open the xlt similar to double clicking the
file?
 
S

strive4peace

Hi Henk,

if you want to make it an XLS file, use the XLS extension
when you do the Filecopy instead of XLT

open the copy, not the source with followhyperlink

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
Joined
May 24, 2013
Messages
1
Reaction score
0
hello

can someone answer this question

"Hi strive,
I want to open a template, but your code
> application.followhyperlink "c:\path\filename.xlt" // (mark xlT)

opens the xlt as such. How can I open the xlt similar to double clicking the
file?"

tq
 

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