Macro to save reports

Techfi

New Member
Joined
Mar 4, 2003
Messages
33
I have a macro that saves daily reports to .rtf Is it possible to have the current date in as part of the file name?
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Yes, it is possible. Could you post your code that saves the file?
 
Upvote 0
here is the code for one of the reports to be saved by the macro.

DoCmd.OpenReport "Dupe Asset Report", acPreview, "", ""
DoCmd.OutputTo acReport, "Dupe Asset Report", "RichTextFormat(*.rtf)", "q:\db checks\daily reports\dupe asset.rtf", False, ""
DoCmd.Close acReport, "Dupe Asset Report"
 
Upvote 0
How about this:

Code:
DoCmd.OpenReport "Dupe Asset Report", acPreview, "", "" 
DoCmd.OutputTo acReport, "Dupe Asset Report", "RichTextFormat(*.rtf)", "q:\db checks\daily reports\dupe asset" & Format(Now(), "yyyymmdd") & ".rtf", False, "" 
DoCmd.Close acReport, "Dupe Asset Report"

You can change the date format to any you like.
 
Upvote 0
that works great. Thanks! The only question I have left is how to save the code as a macro. To get the code to you, i converted it to a module, and that is where I made the changes and tested it out.
 
Upvote 0
I don't think you can. Macros are great for simple tasks, but are very limited. If you want to do something more complicated (like this), VBA is the way to go.

Using VBA should not be feared. You already converted the macro to VBA. Simply connect your command button to the code instead of a macro.

Let me know if you need any assistance doing this.
 
Upvote 0

Forum statistics

Threads
1,221,604
Messages
6,160,747
Members
451,670
Latest member
Peaches000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top