Save Excel File every wednesday VB Script Help

S

sam76210

Hello Group,
I use the following code to save file as an html at the end of month
with Date stamp.

Sub chem_gas_7day()
Dim newSecond
Dim fname As String

fname = Format(Date, "yyyy-mm")


Sheets("data").Select

If CDate(Format(Range("A2").Value, "mm/dd/yyyy")) =
CDate(DateSerial(Year(Now), Month(Now) + 1, 0)) Then


ActiveWorkbook.Save

ChDir "C:\TEST\"
ActiveWorkbook.SaveAs Filename:="C:\TEST\" & fname & "_Report" &
".html", FileFormat:=xlHtml, _
ReadOnlyRecommended:=False, CreateBackup:=False


Else

Sheets("Report").Select
Range("A1").Select

ActiveWorkbook.Save

ChDir "C:\TEST\"
ActiveWorkbook.SaveAs Filename:="C:\TEST\Report.html",
FileFormat:=xlHtml, _
ReadOnlyRecommended:=False, CreateBackup:=False



End If

End Sub


I wonder if i can save file now every Wednesday with Date stamp (file
name = wednesday date). In other words saving file every 7th day.
Thanks in adavnce for help.
Sam
 
B

Bob Phillips

Sub chem_gas_7day()
Dim newSecond
Dim fname As String

fname = Format(Date, "yyyy-mm-dd")

Sheets("data").Select

If Weekday(Date) = 4 Then

ActiveWorkbook.Save
ChDir "C:\TEST\"
ActiveWorkbook.SaveAs Filename:="C:\TEST\" & fname & "_Report" &
".html", _
FileFormat:=xlHtml, _
ReadOnlyRecommended:=False, _
CreateBackup:=False

Else

Sheets("Report").Select
Range("A1").Select
ActiveWorkbook.Save
ChDir "C:\TEST\"
ActiveWorkbook.SaveAs Filename:="C:\TEST\Report.html", _
FileFormat:=xlHtml, _
ReadOnlyRecommended:=False, _
CreateBackup:=False

End If

End Sub

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top