Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Mar 2001
    Location
    Cheltenham, Pennsylvania, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Error handling (in Word VBA environment) (Word 2003 ver 11.8169)

    Is there an apparent reason why this attempt at error handling fails? The system stops execution with an error 53 at the "open file" attempt, rather than responding to the error handler as intended. Could someone point me in the right direction please? Thanks.


    Sub LoadFromStorage(name As String, DateOfService As String)
    Dim name_date As String
    On Error GoTo ErrorHandler:
    name_date = ActiveDocument.Path & Application.PathSeparator & name & "," & DateOfService & ".txt"
    Open name_date For Input As #1 'An anticipated Error 53 (file not found) occurs here in some intended circumstances
    .
    .
    ErrorHandler:
    Select Case Err.Number
    Case 53
    MsgBox ("That name and date combination were not found. Check spelling...yada yada...")
    Case Else
    MsgBox ("Some other error occurred.")
    End Select

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Error handling (in Word VBA environment) (Word 2003 ver 11.8169)

    Select Tools | Options in the Visual Basic Editor.
    Activate the General tab.
    Make sure that you haven't selected "Break on All Errors" in the Error Trapping section.
    "Break on Unhandled Errors" is the recommended setting.

  3. #3
    Star Lounger
    Join Date
    Mar 2001
    Location
    Cheltenham, Pennsylvania, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error handling (in Word VBA environment) (Word 2003 ver 11.8169)

    Bullseye! Hans, I cannot thank you enough.

Posting Permissions

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