Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
DP7 DP7 is offline
external usenet poster
 
Posts: 54
Default Macro Time stamp Help

Hi I need some help to get my macro working properly. I need it to save a
file with the days date @ the end. I got that part working but I can't get
the time to show up in the file name.When I add the h:mm to the macro it
fails to run. Any help would be welcome. The macro I am using is shown below.
Thanks
ActiveWorkbook.SaveAs Filename:= _
"R:\Production Reports\Production Summary Report\Daily Production
Summary Copies\Production Summary Report Master" & Format(Now,
"mm-dd-yyyy_H:MM") & ".xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Application.Quit
ThisWorkbook.Close SaveChanges:=True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Macro Time stamp Help

The colons are no good. How about:

Sub urbia()
s1 = "C:\db7 "
s2 = Format(Now, "mm-dd-yy hh-mm")
s3 = s1 & s2 & ".xls"
ActiveWorkbook.SaveAs Filename:=s3
End Sub
--
Gary''s Student - gsnu200740


"DP7" wrote:

Hi I need some help to get my macro working properly. I need it to save a
file with the days date @ the end. I got that part working but I can't get
the time to show up in the file name.When I add the h:mm to the macro it
fails to run. Any help would be welcome. The macro I am using is shown below.
Thanks
ActiveWorkbook.SaveAs Filename:= _
"R:\Production Reports\Production Summary Report\Daily Production
Summary Copies\Production Summary Report Master" & Format(Now,
"mm-dd-yyyy_H:MM") & ".xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Application.Quit
ThisWorkbook.Close SaveChanges:=True
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,836
Default Macro Time stamp Help

Very generic, but try the code below (found bits and pieces on this DG a
while back; some code is my own design):


Public Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function ReturnUserName() As String
' returns the NT Domain User Name
Dim rString As String * 255, sLen As Long, tString As String
tString = ""
On Error Resume Next
sLen = GetUserName(rString, 255)
sLen = InStr(1, rString, Chr(0))
If sLen 0 Then
tString = Left(rString, sLen - 1)
Else
tString = rString
End If
On Error GoTo 0
ReturnUserName = LCase(Trim(tString))
End Function


Sub DateTime()
Sheets("Time Stamp").Select


Range("A1").Select
Selection = "=ReturnUserName()"
Range("A2").Select
Selection = "=now()"
Selection.NumberFormat = "h:mm"
Range("A3").Select
Selection = "=today()"

Range("4:4").Select
Selection.EntireRow.Insert


Range("B3:CA3").Select
Selection.Copy

Range("B4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False

Range("A4").Select
ActiveCell.FormulaR1C1 = "=IF(RC[1]<"""",ROW()-3,"""")"

Range("A4").Select
Selection.AutoFill Destination:=Range("A4:A1002")
Range("A4:A1002").Select

Range("A1").Select
End Sub





"DP7" wrote:

Hi I need some help to get my macro working properly. I need it to save a
file with the days date @ the end. I got that part working but I can't get
the time to show up in the file name.When I add the h:mm to the macro it
fails to run. Any help would be welcome. The macro I am using is shown below.
Thanks
ActiveWorkbook.SaveAs Filename:= _
"R:\Production Reports\Production Summary Report\Daily Production
Summary Copies\Production Summary Report Master" & Format(Now,
"mm-dd-yyyy_H:MM") & ".xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Application.Quit
ThisWorkbook.Close SaveChanges:=True
End Sub

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
Insert Time Stamp when macro is run Nagesh Excel Discussion (Misc queries) 3 March 13th 07 06:11 AM
Time Stamp DAI Excel Worksheet Functions 8 November 27th 06 07:23 PM
Time Stamp japc90 Excel Discussion (Misc queries) 7 August 22nd 06 04:19 PM
Time Stamp Andrew C Excel Worksheet Functions 2 July 27th 06 05:25 AM
Time Stamp sunderland27 Excel Discussion (Misc queries) 3 April 19th 06 07:05 PM


All times are GMT +1. The time now is 07:43 AM.

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"