Export to Excel - Date in Filename

G

Guest

Hi

When exporting a file to Excel, is it possible to automatically include the
date (and time?) that the export took place in the filename?
At the moment, I'm using a command button to invoke the export. Here's the
code:

DoCmd.TransferSpreadsheet acExport, 8, "VRM for Export", "C:\My
Documents\FILE", True

If it's possible to do this another way, I'll happily do it.
Any advice on this one?
Thanks
rich
 
G

Guest

DoCmd.TransferSpreadsheet acExport, 8, "VRM for Export", "C:\My
Documents\FILE" & Cstr(Now), True
 
G

Guest

When exporting a file to Excel, is it possible to automatically include the
date (and time?) that the export took place in the filename?

Try:

Dim sToday As String

sToday = Format(Date, "mmddyyyy") & "_" & Format(Time, "hhmm")
DoCmd.TransferSpreadsheet acExport, 8, "VRM for Export", "C:\My
Documents\FILE" & sToday & ".xls", True

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
G

Guest

Thanks guys.

Klatuu's suggestion generates "/" symbols in the filename which can't be
saved. Gunny's works nicely and will make things much easier to manage.

.....apprecciated!
rich
 

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