LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Adding date to file name when saving and over writing a existi

You can't use :'s in file names. You could use dashes or underscores.

Format(now, "yyyymmdd_hh-mm-ss")

Personally, I like that first suggestion's format.

More options...

Format(Now, "yyyymmdd_hh-mm-ss AM/PM")
or
Format(Now, "yyyymmdd_hh-mm-ssAM/PM")
(if you don't like the 24 hour time)

Nils Titley wrote:

Dave

Thank works but the time looks weired. I had trouble recognizing it. Can't
I make it look more like time? Say 12:11:30 ? There must be a better way?

Thanks for your help.

"Dave Peterson" wrote:

NewName = "C:\temp\lift logger report\Lift Logger Process Report " _
& Format(now, "yyyymmdd_hhmmss") & ".xls"

Notice that the code uses Now instead of Date.

I like the yyyymmdd_hhmmss format (descending order of units of time). But you
could change it to what you like.



Nils Titley wrote:

Dave

The date is working well but now I want to add time to the file. I thought
I could do this but it doesn't like it. What do I have to do, please?

NewName = "C:\temp\lift logger report\Lift Logger Process Report " _
& Format(Date, "ddmmyy") & Time & ".xls"

Thanks

"Dave Peterson" wrote:

It was a stupid typo.

I meant this:

wbnew.saveas filename:=newname, fileformat:=xlworkbooknormal

(I like being specific.)



Nils Titley wrote:

Dave,

wbnew.saveas filename:=newname, fileformat:=newname

It worked if I removed the " ,fileformat:=newname". What is that doing and
why won't it work with it?

Thanks

"Dave Peterson" wrote:

Dim NewName as string
NewName = "C:\temp\lift logger\lift logger process " _
& format(date, "mmddyy") & ".xls"

application.displayalerts = false
wbnew.saveas filename:=newname, fileformat:=newname
application.displayalerts = true

========
If you didn't know the name of the workbook, you could strip the .xls (and
mmddyy if you had it), too.

Nils Titley wrote:

I want to add a date at end of the file name. How do I do that?

Also I want to over write a file if it exist at this location but I don't
want a box to pop up.

Dim WBNew As Workbook

WBNew.SaveAs "C:\Temp\Lift Logger\Lift Logger Process.xls"

Look like this: Lift Logger Process 031908.xls

Thanks

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Seeing existing file names when saving jkiser Excel Discussion (Misc queries) 1 December 12th 08 06:27 PM
Date format/Writing to a file problem clayton Excel Discussion (Misc queries) 0 August 8th 06 01:31 AM
Ranges, adding a column to a named print range then saving the file [email protected] Excel Programming 1 April 27th 06 01:42 AM
sharing violation while saving file after adding this macro Mike Molyneaux Excel Programming 0 March 1st 06 05:20 PM
Saving over an existing file (updating an HTM file) No Name Excel Programming 2 December 3rd 03 06:19 PM


All times are GMT +1. The time now is 09:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"