PDA

View Full Version : [SOLVED] Auto Save With Date



Kenny Lewis
08-03-2005, 01:26 AM
Hello everybody,

Please help me out. I am using [copied] the following code to automatically save a file with a filename and the current date. It works on my C: perfectly, but now I need to make the workbook available to everyone. Here is the problem, even when I change the directory from C: to our shared server, the file continues to save itself on my, or any other users local PC. What do I need to do?

Thanks, Kenny.



Option Explicit
Sub SvMe()
'Saves filename as value of A1 plus the current date
Dim newFile As String, fName As String
' Don't use "/" in date, invalid syntax
fName = Range("A1").Value
'Change the date format to whatever you'd like, but make sure it's in quotes
newFile = fName & " " & Format$(Date, "mmm-dd-yyyy")
' Change directory to suit your PC, including USER NAME
ChDir "S:\Logistics\A Warehouse\Mechanical Handling\Check Lists"
ActiveWorkbook.SaveAs Filename:=newFile
End Sub

Killian
08-03-2005, 01:44 AM
Hi Kenny and welcome to VBAX :hi:

The FileNAme parameter of SaveAs can in fact be a full path so I'd be inclined to add the default network as a string constant


Option Explicit
Public Const DEFAULT_PATH As String = "S:\Logistics\A Warehouse\Mechanical Handling\Check Lists\"
'
Sub SvMe()
'Saves filename as value of A1 plus the current date
Dim newFile As String, fName As String
' Don't use "/" in date, invalid syntax
fName = Range("A1").Value
'Change the date format to whatever you'd like, but make sure it's in quotes
newFile = DEFAULT_PATH & fName & " " & Format$(Date, "mmm-dd-yyyy")
ActiveWorkbook.SaveAs Filename:=newFile
End Sub

Bob Phillips
08-03-2005, 03:24 AM
You need to do a


ChDrive "S:\Logistics\A Warehouse\Mechanical Handling\Check Lists"

as well as a ChDir

Kenny Lewis
08-03-2005, 05:42 AM
Hello,

Nice work people, now everybody is happy in forktruck town.

Thank you very much, Kenny.