Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error on SaveAs Macro
I got this code from this forum and use it on a spread sheet, it works fine
in till you save a second time and then it ask "A file.... by this name already exits, do you want to save it?" if I choose OK then the macro works fine, but if I choose NO or Cancel then I get an error "Run time error 1004; Method 'Saveas' of Object_Workbook failed". Is not really that important but I would like it to just to work right! It does what it supposed to do except for the annoying message! Thank for your help in advance Kevin Brenner Sub SaveNowDate() Dim wb As Workbook Dim strdate As String strdate = Format(Now, "mm-dd-yyyy") Set wb = ActiveWorkbook With wb .SaveAs Sheets(1).Range("F3").Value _ & " " & strdate & ".xls" End With Cancel = True End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error on SaveAs Macro
I was able to find a solution may not be the correct one but it seems to
work. I added a line "On Error Resume Next" Sub SaveNowDate() Dim wb As Workbook Dim strdate As String strdate = Format(Now, "mm-dd-yyyy") Set wb = ActiveWorkbook With wb On Error Resume Next .SaveAs Sheets(2).Range("g1").Value _ & " " & strdate & ".xls" End With Cancel = True End Sub "Kevin" ! wrote in message ... I got this code from this forum and use it on a spread sheet, it works fine in till you save a second time and then it ask "A file.... by this name already exits, do you want to save it?" if I choose OK then the macro works fine, but if I choose NO or Cancel then I get an error "Run time error 1004; Method 'Saveas' of Object_Workbook failed". Is not really that important but I would like it to just to work right! It does what it supposed to do except for the annoying message! Thank for your help in advance Kevin Brenner Sub SaveNowDate() Dim wb As Workbook Dim strdate As String strdate = Format(Now, "mm-dd-yyyy") Set wb = ActiveWorkbook With wb .SaveAs Sheets(1).Range("F3").Value _ & " " & strdate & ".xls" End With Cancel = True End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
SaveAs wk3 file type error message | Excel Discussion (Misc queries) | |||
SaveAs method error | Excel Discussion (Misc queries) | |||
SaveAs in Macro | Excel Discussion (Misc queries) | |||
Saveas Macro | Excel Discussion (Misc queries) | |||
error message with saveas | Excel Discussion (Misc queries) |