+ Reply to Thread
Results 1 to 6 of 6

Error 400

  1. #1
    Forum Contributor
    Join Date
    11-20-2005
    Posts
    256

    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.

    Please Login or Register  to view this content.
    Any direction on this would shurly be appreciated.
    Thx
    Dave
    "The game is afoot Watson"

  2. #2
    Bob Phillips
    Guest

    Re: 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"
    <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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. #3
    Forum Contributor
    Join Date
    11-20-2005
    Posts
    256
    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
    Quote Originally Posted by Bob Phillips
    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"
    <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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
    >

  4. #4
    Bob Phillips
    Guest

    Re: Error 400

    I tried it and found out.

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Desert Piranha"
    <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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"
    > > <[email protected]> wrote in
    > > message
    > > news:[email protected]...
    > > >
    > > > 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. #5
    Forum Contributor
    Join Date
    11-20-2005
    Posts
    256
    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
    Quote Originally Posted by Bob Phillips
    I tried it and found out.

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Desert Piranha"
    <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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"
    > > <[email protected]> wrote in
    > > message
    > > news:[email protected]...
    > > >
    > > > 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
    >

  6. #6
    Bob Phillips
    Guest

    Re: Error 400

    My pleasure Dave.

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Desert Piranha"
    <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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"
    > > <[email protected]> wrote in
    > > message
    > > news:[email protected]...
    > > >
    > > > 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"
    > > > > <[email protected]> wrote

    > > in
    > > > > message
    > > > >

    > > news:[email protected]...
    > > > > >
    > > > > > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1