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

I need to save a file with the following parameters. "Location 8/12/08" The
"Location" will be a static value but the date needs to be the sunday for the
previous week.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Save As name

Greg,

You won't be able to include the slash character as part of your filename,
so maybe use the underscore character.

Sub test()
Dim dtPreviousSunday As Date
Dim i As Integer

i = Application.WorksheetFunction.Weekday(Date)
If i = 1 Then
dtPreviousSunday = Date - 7
Else
i = i - 1
dtPreviousSunday = Date - (i + 7)
End If

ThisWorkbook.SaveAs "Z:\TEMP\Location " & Format(dtPreviousSunday, "mm_dd_yy")

End Sub



--
Hope that helps.

Vergel Adriano


"Greg H." wrote:

I need to save a file with the following parameters. "Location 8/12/08" The
"Location" will be a static value but the date needs to be the sunday for the
previous week.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Save As name

Works perfectly, thanks so much!

"Vergel Adriano" wrote:

Greg,

You won't be able to include the slash character as part of your filename,
so maybe use the underscore character.

Sub test()
Dim dtPreviousSunday As Date
Dim i As Integer

i = Application.WorksheetFunction.Weekday(Date)
If i = 1 Then
dtPreviousSunday = Date - 7
Else
i = i - 1
dtPreviousSunday = Date - (i + 7)
End If

ThisWorkbook.SaveAs "Z:\TEMP\Location " & Format(dtPreviousSunday, "mm_dd_yy")

End Sub



--
Hope that helps.

Vergel Adriano


"Greg H." wrote:

I need to save a file with the following parameters. "Location 8/12/08" The
"Location" will be a static value but the date needs to be the sunday for the
previous week.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Save As name

i = Application.WorksheetFunction.Weekday(Date)
If i = 1 Then
dtPreviousSunday = Date - 7
Else


In Vba, another technique is to switch the week reference to the following
day (ie Monday)

dtPreviousSunday = Date - Weekday(Date, vbMonday)

--
HTH :)
Dana DeLouis


"Greg H." wrote in message
...
Works perfectly, thanks so much!

"Vergel Adriano" wrote:

Greg,

You won't be able to include the slash character as part of your
filename,
so maybe use the underscore character.

Sub test()
Dim dtPreviousSunday As Date
Dim i As Integer

i = Application.WorksheetFunction.Weekday(Date)
If i = 1 Then
dtPreviousSunday = Date - 7
Else
i = i - 1
dtPreviousSunday = Date - (i + 7)
End If

ThisWorkbook.SaveAs "Z:\TEMP\Location " & Format(dtPreviousSunday,
"mm_dd_yy")

End Sub



--
Hope that helps.

Vergel Adriano


"Greg H." wrote:

I need to save a file with the following parameters. "Location
8/12/08" The
"Location" will be a static value but the date needs to be the sunday
for the
previous week.

Thanks



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
Save, save as, page setup dimmed out in unprotected excel sheet? ccKeithJ Excel Discussion (Misc queries) 3 December 14th 07 07:07 PM
SAVE and SAVE AS options disappeared from the drop down FILE menu [email protected] Excel Discussion (Misc queries) 2 July 12th 07 09:14 AM
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
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 02:57 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"