+ Reply to Thread
Results 1 to 2 of 2

Error Handler and Error 1004

  1. #1
    ExcelMonkey
    Guest

    Error Handler and Error 1004

    I have been using an Error Handler in a routine. I have
    been getting an Error 1004. When I use the Error Handler,
    the routine seems to go to the Error Handler but does not
    bring up the message box as dictated by the Error
    Handler. Is this because Error 1004 is an error generated
    outside of VBA? Note that when I do not use the Error
    HAndler code, VBA naturally displays an error alert with
    the error number (1004). Why does this not still happen
    when I use this error handler?


    On Error Goto Err_Hndlr

    'Code here

    CleanUp:
    Application.StatusBar = ""
    Application.ScreenUpdating = True
    Other stuff to clean up
    Exit Sub

    Err_Hndlr:
    MsgBox Err.Number & Err.Description
    Resume CleanUp

    End Sub


  2. #2
    Jim Rech
    Guest

    Re: Error Handler and Error 1004

    I don't see anything wrong with the code you presented. It might be in
    something you didn't show as, fleshing out your example, the message box
    appears for me:

    Sub a()
    Dim x As Integer
    On Error GoTo Err_Hndlr
    x = 1 / 0
    CleanUp:
    MsgBox "exiting"
    Exit Sub

    Err_Hndlr:
    MsgBox Err.Number & " " & Err.Description
    Resume CleanUp
    End Sub


    --
    Jim Rech
    Excel MVP
    "ExcelMonkey" <[email protected]> wrote in message
    news:[email protected]...
    |I have been using an Error Handler in a routine. I have
    | been getting an Error 1004. When I use the Error Handler,
    | the routine seems to go to the Error Handler but does not
    | bring up the message box as dictated by the Error
    | Handler. Is this because Error 1004 is an error generated
    | outside of VBA? Note that when I do not use the Error
    | HAndler code, VBA naturally displays an error alert with
    | the error number (1004). Why does this not still happen
    | when I use this error handler?
    |
    |
    | On Error Goto Err_Hndlr
    |
    | 'Code here
    |
    | CleanUp:
    | Application.StatusBar = ""
    | Application.ScreenUpdating = True
    | Other stuff to clean up
    | Exit Sub
    |
    | Err_Hndlr:
    | MsgBox Err.Number & Err.Description
    | Resume CleanUp
    |
    | End Sub
    |



+ 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