How to open .xlt in VBA?

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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

*
 
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?
 
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

*
 
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
 
Back
Top