Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Save with dates

Following is my code, basically this report is run weekly from previous
Monday date to Sunday date. This macro does everything except add in those
dates to the file name. Any suggestions?

Dim wb As Workbook
Dim ws As Worksheet
Dim x As Variant
Dim y As Variant
Dim strFileName As String
Set wb = ActiveWorkbook
Set ws = wb.Worksheets("idrmterm")
x = Format(Date - 7, mm - dd - yy)
y = Format(Date - 1, mm - dd - yy)
Dim strPath As String
strPath = "H:\REPORTS\Every Monday Reports\"
'===strFileName = x & " " & y & ws & ".xls"<<<===
ActiveWorkbook.SaveAs Filename:=strPath & strFileName
Set wb = Nothing
Set ws = Nothing
Application.Dialogs(xlDialogSendMail).Show
ActiveWorkbook.Close
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Save with dates

strPath = "H:\REPORTS\Every Monday Reports\"
strFileName = x & " " & y & ws.Name & ".xls"

--
Regards,
Tom Ogilvy

"CV323" wrote:

Following is my code, basically this report is run weekly from previous
Monday date to Sunday date. This macro does everything except add in those
dates to the file name. Any suggestions?

Dim wb As Workbook
Dim ws As Worksheet
Dim x As Variant
Dim y As Variant
Dim strFileName As String
Set wb = ActiveWorkbook
Set ws = wb.Worksheets("idrmterm")
x = Format(Date - 7, mm - dd - yy)
y = Format(Date - 1, mm - dd - yy)
Dim strPath As String
strPath = "H:\REPORTS\Every Monday Reports\"
'===strFileName = x & " " & y & ws & ".xls"<<<===
ActiveWorkbook.SaveAs Filename:=strPath & strFileName
Set wb = Nothing
Set ws = Nothing
Application.Dialogs(xlDialogSendMail).Show
ActiveWorkbook.Close
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Save with dates

Thanks Tom.

It works, except that the dates are not coming up as mm-dd-yy instead
mm/dd/yy and it won't save the file. What do you suggest?

This is how it reads now:

Dim wb As Workbook
Dim ws As Worksheet
Dim x As Date
Dim y As Date
Dim strFileName As String
Set wb = ActiveWorkbook
Set ws = wb.Worksheets("idrmterm")
x = Format(Date - 7, mm - dd - yy)
y = Format(Date - 1, mm - dd - yy)
Dim strPath As String
strPath = "H:\REPORTS\Every Monday Reports\"
strFileName = x & " " & y & ws.Name & ".xls"
ActiveWorkbook.SaveAs Filename:=strPath & strFileName
Set wb = Nothing
Set ws = Nothing
Application.Dialogs(xlDialogSendMail).Show
ActiveWorkbook.Close

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Save with dates

Try

x = Format(Date - 7, "mm - dd - yy")
y = Format(Date - 1, "mm - dd - yy")

Putting in "" worked for me on asimilar thing

"CV323" wrote:

Thanks Tom.

It works, except that the dates are not coming up as mm-dd-yy instead
mm/dd/yy and it won't save the file. What do you suggest?

This is how it reads now:

Dim wb As Workbook
Dim ws As Worksheet
Dim x As Date
Dim y As Date
Dim strFileName As String
Set wb = ActiveWorkbook
Set ws = wb.Worksheets("idrmterm")
x = Format(Date - 7, mm - dd - yy)
y = Format(Date - 1, mm - dd - yy)
Dim strPath As String
strPath = "H:\REPORTS\Every Monday Reports\"
strFileName = x & " " & y & ws.Name & ".xls"
ActiveWorkbook.SaveAs Filename:=strPath & strFileName
Set wb = Nothing
Set ws = Nothing
Application.Dialogs(xlDialogSendMail).Show
ActiveWorkbook.Close

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
How to change 2006 calendar to 2007 and save dates in Excel Brent P. Excel Discussion (Misc queries) 2 December 27th 06 04:15 PM
Disable save, save as, but allow save via command button TimN Excel Programming 10 September 1st 06 07:05 PM
How to diasble save and save as menu but allow a save button hon123456 Excel Programming 1 June 12th 06 09:50 AM
How to create command button to save the dates and time Ken Vo Excel Discussion (Misc queries) 6 January 5th 06 04:18 AM
Totally Disabling (^ save ) (Save as) and Save Icon – Which code do I use: harpscardiff[_10_] Excel Programming 8 November 10th 05 12:24 PM


All times are GMT +1. The time now is 06:05 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"