Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding time to a file save..

Status
Not open for further replies.

thetambarineman

Technical User
Feb 29, 2000
63
GB
I've become stuck on a small but nagging problem. When I want to save a file-using the Filecopy proc. The thing is that once i try to transfer the file over i want to add a time to it.. i.e. Employeeddmmyyyy.mdb

where ddmmyyyyy is the date. The thing is when you try to stick that in i.e. "Employee" & now & ".mdb" this crashes out because Windows doesn't support the "\" char while saving a file.
Does anyone know of a way around this??

Thanks in advance?

Paul..
 
Here is a snip of code I wrote for a filecopy routine in VBS. They should work fairly the same in VB (Some modifications my be needed. ;) )


dim dtmMonth, dtmDay, dtmYear, dtmMDY

dtmMonth = Month(date)
dtmDay = Day(date)
dtmYear = Year(date)
dtmMDY = dtmMonth & "-" & dtmDay & "-" & dtmYear
set ExcelSheet = CreateObject("Excel.sheet") 'Creating an Instance
'of the Excel Object
ExcelSheet.Application.Visible = true 'Show Excel

' Add code to make excel do some work here

ExcelSheet.SaveAs"C:\SResults" & dtmMDY & ".xls"
ExcelSheet.Application.quit

-------This works great. the filename is SResults1162000.xls (Example for today.)

HTH

Steve


Stephen Boston
stephenb@nbarizona.com
 
"Employee" & replace(Date$,"-","") & ".mdb" will give you Employee11062000





David Paulson


 
Try this:
Dat2 = "Employee" & Format(Now, "mm-dd-yyyy hh:mm:ss") & ".mdb"
You can also accomplish this without changing your code by changing the date separator to "-" in Control Panel "Regional Configurations". The downside is that your programs will no longer use "/"in dates. Personally I've been using "-" for years because I think it looks better!!
 
If all you want is ddmmyyyy as the date part of the file name, use Format(Now(), "ddmmyyyy") to format the current date.

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top