Wrox Programmer Forums
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 16th, 2005, 09:33 AM
Friend of Wrox
Join Date: Sep 2005
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Corey
Default OutputTo Macro Question

When using the Macro “OutputTo” how can I have it saved automatically with today’s date with the title? Or can anyone direct me to a website that can help?

Old September 19th, 2005, 11:36 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts

I'd suggest you use a module rather than a macro.
The easiest way to do it would be this:
Open your macro in design view,
choose save as, then select as Module
You may as well leave the error handling and comments boxes checked
Then open the module (which will be named something like "Converted Macro- Macro1"
The command that actually does the work is the line
Where you've got the existing filename in that line, change the code to include today's date (remembering that slashes can't be used)
So you'll start out with something along the lines of
DoCmd.OutputTo acTable, "YourTable", "MicrosoftExcelBiff8(*.xls)", "C:\something.xls", False, "", 0
and end up with something like:
DoCmd.OutputTo acTable, "YourTable", "MicrosoftExcelBiff8(*.xls)", "D:\Stuff_" & Format(Now(), "yyyymmdd") & ".xls", False, "", 0
Which will give you the filename something like D:\Stuff_20050102.xls

Next problem is calling that code.

To make it easier (and if you prefer macros to real coding), you could make another macro, with the action being "RunCode", and then select the function from there.



I am a loud man with a very large hat. This means I am in charge
(Edited due to type in code)

Similar Threads
Thread Thread Starter Forum Replies Last Post
OutputTo .csv nspeelman Access 7 November 17th, 2008 01:37 PM
docmd.outputto Scripts82 Access VBA 0 March 9th, 2006 04:19 AM
Outputto exceeded limit of rows Renee Voice Access VBA 2 February 26th, 2006 04:47 PM
outputto command ajmil11 Access 1 February 1st, 2006 08:21 AM
OutputTo option for HTML file rry2k Access 2 May 31st, 2004 10:08 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.