Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default 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
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
SaveAs wk3 file type error message Ken Warthen[_2_] Excel Discussion (Misc queries) 1 December 9th 09 10:42 PM
SaveAs method error Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 3 October 6th 09 09:05 PM
SaveAs in Macro gfkbob[_2_] Excel Discussion (Misc queries) 2 April 12th 07 10:52 PM
Saveas Macro Nigel Excel Discussion (Misc queries) 3 May 11th 05 01:15 PM
error message with saveas DJA Excel Discussion (Misc queries) 6 February 17th 05 06:03 PM


All times are GMT +1. The time now is 09:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"