M
MegaDETH
I get a .xls file sent to me via email everyday that needs to be saved
to a certain folder with the days date so I have a macro (taken from
this site) that does everything I want BUT I need the filename to be
the date I save it 070705.xls
Sorry I am a complete noob at macros as I am just learning Excel so if
anyone can tell me the line I need to replace and what it should be I
would appreciate it.
edit: also I do not want the xls file to close.
Thanks
Sub indy()
Dim Response As String
Dim msg As String
Dim Style As String
Dim sPath As String
Dim sFilename As String
Dim ans
msg = "Are you sure you want to Exit the application and Close Excel?"
Style = vbYesNo + vbInformation + vbDefaultButton2
Response = MsgBox(msg, Style)
If Response = vbYes Then
sPath = "g:\indymicro\"
sFilename = Format(Worksheets("Sheet1").Range("A1").Value,
"yyyy-mm-dd") "mm-dd-yyyy")
ans = MsgBox("Save File As " & sFilename)
If ans = vbOK Then
ActiveWorkbook.SaveAs sPath & sFilename
ActiveWorkbook.Close savechanges:=True
Application.Exit
Application.StatusBar = "Application Closing."
End If
Else
ActiveWorkbook.Activate
End If
End Sub
to a certain folder with the days date so I have a macro (taken from
this site) that does everything I want BUT I need the filename to be
the date I save it 070705.xls
Sorry I am a complete noob at macros as I am just learning Excel so if
anyone can tell me the line I need to replace and what it should be I
would appreciate it.
edit: also I do not want the xls file to close.
Thanks
Sub indy()
Dim Response As String
Dim msg As String
Dim Style As String
Dim sPath As String
Dim sFilename As String
Dim ans
msg = "Are you sure you want to Exit the application and Close Excel?"
Style = vbYesNo + vbInformation + vbDefaultButton2
Response = MsgBox(msg, Style)
If Response = vbYes Then
sPath = "g:\indymicro\"
sFilename = Format(Worksheets("Sheet1").Range("A1").Value,
"yyyy-mm-dd") "mm-dd-yyyy")
ans = MsgBox("Save File As " & sFilename)
If ans = vbOK Then
ActiveWorkbook.SaveAs sPath & sFilename
ActiveWorkbook.Close savechanges:=True
Application.Exit
Application.StatusBar = "Application Closing."
End If
Else
ActiveWorkbook.Activate
End If
End Sub