View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Sharad Naik Sharad Naik is offline
external usenet poster
 
Posts: 212
Default Block saving using dates

See Code below

Sharad

Sub MultiSave()

Set fs = CreateObject("Scripting.FileSystemObject")
mypath = "c:\My Documents\"

If Not fs.FolderExists(mypath) Then
MsgBox "Folder " & mypath & " does not exist. Please create the folder
first."
'OR you can add code to create the folder.
Exit Sub
End If

dt = DatePart("d", Date)
mnth = DatePart("m", Date)
yr = DatePart("yyyy", Date)

Select Case mnth
Case 1
mnth = "Jan"
Case 2
mnth = "Feb"
Case 3
mnth = "Mar"
Case 4
mnth = "Apr"
Case 5
mnth = "May"
Case 6
mnth = "Jun"
Case 7
mnth = "Jul"
Case 8
mnth = "Aug"
Case 9
mnth = "Sep"
Case 10
mnth = "Oct"
Case 11
mnth = "Nov"
Case 12
mnth = "Dec"
End Select

allok = "yes"
For i = 0 To 6
spath = mypath & dt + i & " " & mnth & " " & yr & ".xls"
If fs.FileExists(spath) Then
MsgBox "File name " & spath & " already exists. Hence will not be
saved."
allok = "no"
GoTo 10
End If
ThisWorkbook.SaveAs spath
10 Next i
If allok = "yes" Then
MsgBox "All files saved successfully"
Else
MsgBox "Some (or all) files could not be saved."
End If

End Sub

"Bobby" wrote in message
...
I'm trying to make a macro that will save a workbook to 7 files, example,
it
saves as 17 oct 04
18 oct 04
19 oct 04
and so on, so with one click i can create the next 7 days workbooks.
if someone can help it would be great.
Thankyou