#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error 400


Hi all,

I have this Save As code linked to a Option Button.
Everything works as i want it to, except when there is already been a
file saved with the current date.
Then i get a message box asking if i want to overwrite the file.
I DO want that.

BUT if i answer "No" or "Cancel" i get a Visual Basic "Error 400"
thingy.
I DON'T want that error message.

If i put like "Application.DisplayAlerts = False" in then it also
blocks the "Do i want to overwrite dialog",
which i want to keep.


Code:
--------------------
Private Sub SaveAsTo()
Application.ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "\" & _
"myfile " & Format(Date, "mm-dd-yyyy") & ".xls"
End Sub
--------------------
Any direction on this would shurly be appreciated.


--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=499135

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Error 400

Try this

On Error Resume Next
ActiveWorkbook.SaveAs _
Filename:=ActiveWorkbook.Path & _
"myfile " & Format(Date, "mm-dd-yyyy") & ".xls"
If Err.Number = 1004 Then
MsgBox "cancelled"
End If
On Error GoTo 0


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Desert Piranha"
<Desert.Piranha.21b0yr_1136704226.2156@excelforu m-nospam.com wrote in
message news:Desert.Piranha.21b0yr_1136704226.2156@excelfo rum-nospam.com...

Hi all,

I have this Save As code linked to a Option Button.
Everything works as i want it to, except when there is already been a
file saved with the current date.
Then i get a message box asking if i want to overwrite the file.
I DO want that.

BUT if i answer "No" or "Cancel" i get a Visual Basic "Error 400"
thingy.
I DON'T want that error message.

If i put like "Application.DisplayAlerts = False" in then it also
blocks the "Do i want to overwrite dialog",
which i want to keep.


Code:
--------------------
Private Sub SaveAsTo()
Application.ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path & "\" &

_
"myfile " & Format(Date, "mm-dd-yyyy") & ".xls"
End Sub
--------------------
Any direction on this would shurly be appreciated.


--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile:

http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=499135



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error 400


Hi Bob,

Thx for this. The message box is a nice touch, i like that.
Sooo how do you know that the error number is 1004 ??

Thx again
Dave
Bob Phillips Wrote:
Try this

On Error Resume Next
ActiveWorkbook.SaveAs _
Filename:=ActiveWorkbook.Path & _
"myfile " & Format(Date, "mm-dd-yyyy") & ".xls"
If Err.Number = 1004 Then
MsgBox "cancelled"
End If
On Error GoTo 0


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Desert Piranha"
<Desert.Piranha.21b0yr_1136704226.2156@excelforu m-nospam.com wrote in
message
news:Desert.Piranha.21b0yr_1136704226.2156@excelfo rum-nospam.com...

Hi all,

I have this Save As code linked to a Option Button.
Everything works as i want it to, except when there is already been

a
file saved with the current date.
Then i get a message box asking if i want to overwrite the file.
I DO want that.

BUT if i answer "No" or "Cancel" i get a Visual Basic "Error 400"
thingy.
I DON'T want that error message.

If i put like "Application.DisplayAlerts = False" in then it also
blocks the "Do i want to overwrite dialog",
which i want to keep.


Code:
--------------------
Private Sub SaveAsTo()
Application.ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path &

"\" &
_
"myfile " & Format(Date, "mm-dd-yyyy") & ".xls"
End Sub
--------------------
Any direction on this would shurly be appreciated.


--
Desert Piranha



------------------------------------------------------------------------
Desert Piranha's Profile:

http://www.excelforum.com/member.php...o&userid=28934
View this thread:

http://www.excelforum.com/showthread...hreadid=499135



--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=499135

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Error 400

I tried it and found out.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Desert Piranha"
<Desert.Piranha.21c1ay_1136751301.8023@excelforu m-nospam.com wrote in
message news:Desert.Piranha.21c1ay_1136751301.8023@excelfo rum-nospam.com...

Hi Bob,

Thx for this. The message box is a nice touch, i like that.
Sooo how do you know that the error number is 1004 ??

Thx again
Dave
Bob Phillips Wrote:
Try this

On Error Resume Next
ActiveWorkbook.SaveAs _
Filename:=ActiveWorkbook.Path & _
"myfile " & Format(Date, "mm-dd-yyyy") & ".xls"
If Err.Number = 1004 Then
MsgBox "cancelled"
End If
On Error GoTo 0


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Desert Piranha"
<Desert.Piranha.21b0yr_1136704226.2156@excelforu m-nospam.com wrote in
message
news:Desert.Piranha.21b0yr_1136704226.2156@excelfo rum-nospam.com...

Hi all,

I have this Save As code linked to a Option Button.
Everything works as i want it to, except when there is already been

a
file saved with the current date.
Then i get a message box asking if i want to overwrite the file.
I DO want that.

BUT if i answer "No" or "Cancel" i get a Visual Basic "Error 400"
thingy.
I DON'T want that error message.

If i put like "Application.DisplayAlerts = False" in then it also
blocks the "Do i want to overwrite dialog",
which i want to keep.


Code:
--------------------
Private Sub SaveAsTo()
Application.ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path &

"\" &
_
"myfile " & Format(Date, "mm-dd-yyyy") & ".xls"
End Sub
--------------------
Any direction on this would shurly be appreciated.


--
Desert Piranha



------------------------------------------------------------------------
Desert Piranha's Profile:

http://www.excelforum.com/member.php...o&userid=28934
View this thread:

http://www.excelforum.com/showthread...hreadid=499135



--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile:

http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=499135



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error 400


Hi Bob,
Oh ok, i see. If you run the code from the VBE it then shows the Erro
number.
Cool.
Thx Bob for your help.
Dave
Bob Phillips Wrote:
I tried it and found out.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Desert Piranha"
<Desert.Piranha.21c1ay_1136751301.8023@excelforu m-nospam.com wrote in
messag
news:Desert.Piranha.21c1ay_1136751301.8023@excelfo rum-nospam.com...

Hi Bob,

Thx for this. The message box is a nice touch, i like that.
Sooo how do you know that the error number is 1004 ??

Thx again
Dave
Bob Phillips Wrote:
Try this

On Error Resume Next
ActiveWorkbook.SaveAs _
Filename:=ActiveWorkbook.Path & _
"myfile " & Format(Date, "mm-dd-yyyy") & ".xls"
If Err.Number = 1004 Then
MsgBox "cancelled"
End If
On Error GoTo 0


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Desert Piranha"
<Desert.Piranha.21b0yr_1136704226.2156@excelforu m-nospam.com wrot

in
message


news:Desert.Piranha.21b0yr_1136704226.2156@excelfo rum-nospam.com...

Hi all,

I have this Save As code linked to a Option Button.
Everything works as i want it to, except when there is alread

been
a
file saved with the current date.
Then i get a message box asking if i want to overwrite the file.
I DO want that.

BUT if i answer "No" or "Cancel" i get a Visual Basic "Erro

400"
thingy.
I DON'T want that error message.

If i put like "Application.DisplayAlerts = False" in then i

also
blocks the "Do i want to overwrite dialog",
which i want to keep.


Code:
--------------------
Private Sub SaveAsTo()
Application.ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Pat

&
"\" &
_
"myfile " & Format(Date, "mm-dd-yyyy") & ".xls"
End Sub
--------------------
Any direction on this would shurly be appreciated.


--
Desert Piranha




------------------------------------------------------------------------
Desert Piranha's Profile:
http://www.excelforum.com/member.php...o&userid=28934
View this thread:
http://www.excelforum.com/showthread...hreadid=499135



--
Desert Piranha



------------------------------------------------------------------------
Desert Piranha's Profile:

http://www.excelforum.com/member.php...o&userid=28934
View this thread

http://www.excelforum.com/showthread...hreadid=499135


--
Desert Piranh

-----------------------------------------------------------------------
Desert Piranha's Profile: http://www.excelforum.com/member.php...fo&userid=2893
View this thread: http://www.excelforum.com/showthread.php?threadid=49913



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Error 400

My pleasure Dave.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Desert Piranha"
<Desert.Piranha.21e7bb_1136852401.8161@excelforu m-nospam.com wrote in
message news:Desert.Piranha.21e7bb_1136852401.8161@excelfo rum-nospam.com...

Hi Bob,
Oh ok, i see. If you run the code from the VBE it then shows the Error
number.
Cool.
Thx Bob for your help.
Dave
Bob Phillips Wrote:
I tried it and found out.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Desert Piranha"
<Desert.Piranha.21c1ay_1136751301.8023@excelforu m-nospam.com wrote in
message
news:Desert.Piranha.21c1ay_1136751301.8023@excelfo rum-nospam.com...

Hi Bob,

Thx for this. The message box is a nice touch, i like that.
Sooo how do you know that the error number is 1004 ??

Thx again
Dave
Bob Phillips Wrote:
Try this

On Error Resume Next
ActiveWorkbook.SaveAs _
Filename:=ActiveWorkbook.Path & _
"myfile " & Format(Date, "mm-dd-yyyy") & ".xls"
If Err.Number = 1004 Then
MsgBox "cancelled"
End If
On Error GoTo 0


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Desert Piranha"
<Desert.Piranha.21b0yr_1136704226.2156@excelforu m-nospam.com wrote

in
message

news:Desert.Piranha.21b0yr_1136704226.2156@excelfo rum-nospam.com...

Hi all,

I have this Save As code linked to a Option Button.
Everything works as i want it to, except when there is already

been
a
file saved with the current date.
Then i get a message box asking if i want to overwrite the file.
I DO want that.

BUT if i answer "No" or "Cancel" i get a Visual Basic "Error

400"
thingy.
I DON'T want that error message.

If i put like "Application.DisplayAlerts = False" in then it

also
blocks the "Do i want to overwrite dialog",
which i want to keep.


Code:
--------------------
Private Sub SaveAsTo()
Application.ActiveWorkbook.SaveAs Filename:=ActiveWorkbook.Path

&
"\" &
_
"myfile " & Format(Date, "mm-dd-yyyy") & ".xls"
End Sub
--------------------
Any direction on this would shurly be appreciated.


--
Desert Piranha




------------------------------------------------------------------------
Desert Piranha's Profile:
http://www.excelforum.com/member.php...o&userid=28934
View this thread:
http://www.excelforum.com/showthread...hreadid=499135



--
Desert Piranha



------------------------------------------------------------------------
Desert Piranha's Profile:

http://www.excelforum.com/member.php...o&userid=28934
View this thread:

http://www.excelforum.com/showthread...hreadid=499135



--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile:

http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=499135



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
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) Tim[_36_] Excel Programming 4 April 23rd 04 02:53 AM


All times are GMT +1. The time now is 05:06 PM.

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"