File Save As with date

concreteinterface

Board Regular
Joined
Jul 10, 2008
Messages
144
I am using the following code:

Sub AutoFileSaveWithAutoName()

myFile = Range("A1").Value
ActiveWorkbook.SaveAs "\\server\users\john\Desktop\" & myFile

End Sub



After "myFile = Range("A1").Value" I want to put in the current date so it will read "Blah Blah Blah 05-30-11"

I've tried "myFile = Range("A1").Value & (Date)" and "myFile = Range("A1").Value & document.write(Date)" and did not work.

I really don't know what to use. Any solutions?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Try

Code:
ActiveWorkbook.SaveAs "\\server\users\john\Desktop\" & myFile & " " & Format(Date, "mm-dd-yy") & ".xls"
 
Upvote 0
I thought I had the second part figured out but there's a problem

I'm trying to take the newly named excel file and print one of the sheets out to the default PDF printer. I started with this code:

Sub PrintTo()

Sheets("Quotation").PrintOut

End Sub


The problem is it would name the file the last file I tried to print and not the current one. So I hit the save button and tried again. This worked so I changed the code to:

Sub PrintTo()

ActiveWorkbook.Save
Sheets("Quotation").PrintOut

End Sub


But still it reverts back to the previously printed file name. Is there like a refresh code I can use?
 
Upvote 0

Forum statistics

Threads
1,224,550
Messages
6,179,463
Members
452,915
Latest member
hannnahheileen

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