Save File to specific location and name with date

HomePro

Board Regular
Joined
Aug 3, 2021
Messages
157
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
  6. 2011
  7. 2010
  8. 2007
  9. 2003 or older
  10. Prefer Not To Say
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
I would like to save the file without being prompted at the end of my existing macro.
I would prefer:
A variable to preset the file name
A variable to preset the location
And then the current date.

So i tried :
Sub Save()
FN="Test1"
lc ="C:\documents"
DT= (today)
ActiveWorkbook.SaveAs filename:=LC & FN &DT ".xls"
End Sub

wont work.
Any ideas?
 
If you are able to manually save to that path, then yes. If not, no.
If you are able to save to that path, turn on your Macro Recorder and record yourself manually saving a file to that path.
Then stop the Macro Recorder and view your code to see what that part of your code should look like.
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Cant seem to get this to work.
This is the code i am using.
Can anyone help?

I tried the script below but it did not work..

'Save File
FN = "Mileage - "
DT = Sheets("Sheet1").Cells(1, "m")
FilePath = LC & "\" & FN & DT & ".xls"
LC=https://work.zoho.com/#workdrive/ho...folders/rdj8id0786001aa5c4d2ba095f37928e04cf0" '[this is the desired save to location that i could not get to work]
Application.DisplayAlerts = False
ActiveWorkbook.saveas Filename:=FilePath, FileFormat:=xlExcel8
Application.DisplayAlerts = True
Application.Quit
 
Upvote 0
Please respond to posts 10 and 11.
Have you tried either of those things yet?
 
Upvote 0
Sorry - been away.
Using the macro recorder it defaults to the mapped path. Butif I run it on another pc that is not mapped the same way it fails.
Thats why I wanted to use a unc or in this case web address as the storage is not in my domain.
 
Upvote 0
If you are able to manually save the file to a web address path, then it should be possible to write a macro to automate it.

Step 1: Turn on your Macro Recorder and record yourself manually and successfully saving a file to your desired web address path.
Step 2: Post the macro recorder code here.
 
Upvote 0
well I do not know how to do that - i can only pick the location from the mapped folders in the save as drop down.
Thats why i was asking for help on how to save it to a web location......
 
Upvote 0
Best of luck to you, but I think I'm out. You ask for help but you won't follow recommendations to gather information that might allow further help, and I am weary of trying to coax you into action.
 
Upvote 0
I tried to follow - however I can not post what I can reproduce.
 
Upvote 0
One last attempt:
Thats why I wanted to use a unc or in this case web address as the storage is not in my domain.
Are you able to manually browse to this web address and successfully save your file?
If you are, simply turn on your Macro Recorder, and record yourself doing that exact thing (manually browsing to the web address and saving the file).
Then simply stop the Macro Recorder, view the code you recorded, and copy and paste it here.

If you cannot browse to the web address and save the file manually, then you probably are not going to be able to do it with VBA either.
 
Upvote 0

Forum statistics

Threads
1,215,767
Messages
6,126,777
Members
449,336
Latest member
p17tootie

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