Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default file naming during auto-saveas

Hello,
I am using the following code to automatically do a saveas process to have
my file save as filename_date_time.xls.

Sub SaveAs2()
'
Dim irdate
Dim irtime

Application.ScreenUpdating = False
Application.DisplayAlerts = False

irdate = Month(Now) & Day(Now) & Year(Now) 'Format(Date,"mmddyy")
irtime = FormatDateTime(Round(Time * 24, 0.1) / 24, vbShortTime)
'Format(Time,"hhmm")
irtime = Hour(Now) & Minute(Now) 'could this line be the problem?
On Error Resume Next
ActiveWorkbook.SaveAs "H:\" & "PassCounts_" & irdate & "_" & irtime &
".xls"

Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

The problem I am having is in the time format.
For 12:00 it should show _1200.xls but I am getting _120.xls instead. Can
someone help me with properly formating the time for doing this file saveas
process? I'm sure it is somthing simple but it just keeps illuding me. Thanks
in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default file naming during auto-saveas

Without looking at the details, I'd use something like:

ActiveWorkbook.SaveAs "H:\" & "PassCounts_" _
& format(now,"mmddyy_hhmmss") & ".xls"

Actually, I'd use a format of yyyymmdd_hhmmss. I think it looks nicer and is
easier to sort by in windows explorer.

SJW_OST wrote:

Hello,
I am using the following code to automatically do a saveas process to have
my file save as filename_date_time.xls.

Sub SaveAs2()
'
Dim irdate
Dim irtime

Application.ScreenUpdating = False
Application.DisplayAlerts = False

irdate = Month(Now) & Day(Now) & Year(Now) 'Format(Date,"mmddyy")
irtime = FormatDateTime(Round(Time * 24, 0.1) / 24, vbShortTime)
'Format(Time,"hhmm")
irtime = Hour(Now) & Minute(Now) 'could this line be the problem?
On Error Resume Next
ActiveWorkbook.SaveAs "H:\" & "PassCounts_" & irdate & "_" & irtime &
".xls"

Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

The problem I am having is in the time format.
For 12:00 it should show _1200.xls but I am getting _120.xls instead. Can
someone help me with properly formating the time for doing this file saveas
process? I'm sure it is somthing simple but it just keeps illuding me. Thanks
in advance.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default file naming during auto-saveas

from
irtime = Hour(Now) & Minute(Now) 'could this line be the problem?

to
irtime = Hour(t) & Format(Minute(t), "#00")


"SJW_OST" wrote:

Hello,
I am using the following code to automatically do a saveas process to have
my file save as filename_date_time.xls.

Sub SaveAs2()
'
Dim irdate
Dim irtime

Application.ScreenUpdating = False
Application.DisplayAlerts = False

irdate = Month(Now) & Day(Now) & Year(Now) 'Format(Date,"mmddyy")
irtime = FormatDateTime(Round(Time * 24, 0.1) / 24, vbShortTime)
'Format(Time,"hhmm")
irtime = Hour(Now) & Minute(Now) 'could this line be the problem?
On Error Resume Next
ActiveWorkbook.SaveAs "H:\" & "PassCounts_" & irdate & "_" & irtime &
".xls"

Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

The problem I am having is in the time format.
For 12:00 it should show _1200.xls but I am getting _120.xls instead. Can
someone help me with properly formating the time for doing this file saveas
process? I'm sure it is somthing simple but it just keeps illuding me. Thanks
in advance.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default file naming during auto-saveas

WOW!! That is soo much easier than what I had found before. It makes sense
from start to finish and takes up less area on my screen. Thank you!

"Dave Peterson" wrote:

Without looking at the details, I'd use something like:

ActiveWorkbook.SaveAs "H:\" & "PassCounts_" _
& format(now,"mmddyy_hhmmss") & ".xls"

Actually, I'd use a format of yyyymmdd_hhmmss. I think it looks nicer and is
easier to sort by in windows explorer.

SJW_OST wrote:

Hello,
I am using the following code to automatically do a saveas process to have
my file save as filename_date_time.xls.

Sub SaveAs2()
'
Dim irdate
Dim irtime

Application.ScreenUpdating = False
Application.DisplayAlerts = False

irdate = Month(Now) & Day(Now) & Year(Now) 'Format(Date,"mmddyy")
irtime = FormatDateTime(Round(Time * 24, 0.1) / 24, vbShortTime)
'Format(Time,"hhmm")
irtime = Hour(Now) & Minute(Now) 'could this line be the problem?
On Error Resume Next
ActiveWorkbook.SaveAs "H:\" & "PassCounts_" & irdate & "_" & irtime &
".xls"

Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub

The problem I am having is in the time format.
For 12:00 it should show _1200.xls but I am getting _120.xls instead. Can
someone help me with properly formating the time for doing this file saveas
process? I'm sure it is somthing simple but it just keeps illuding me. Thanks
in advance.


--

Dave Peterson

Reply
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
Auto Naming Worksheets Will Cendrowski[_2_] Excel Discussion (Misc queries) 4 October 23rd 09 02:03 PM
Auto naming Worksheets Will Cendrowski Excel Discussion (Misc queries) 1 October 22nd 09 09:40 PM
Auto file naming Jacquesvv Excel Discussion (Misc queries) 1 June 23rd 09 02:57 PM
Auto naming worksheets Kenny R Excel Discussion (Misc queries) 1 December 7th 06 09:38 PM
Check cells for 'Auto Save As' file naming Shinka Excel Programming 3 October 19th 05 04:16 PM


All times are GMT +1. The time now is 08:24 PM.

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

About Us

"It's about Microsoft Excel"