File already open

I recently added an Add-On entitled "MouseWheel Fix".  Since doing that my On Error routines no longer work.  I went to MSDN On Error statement and added the Code Snippet shown below to my code.  When executed, I get a "File already open" error message at the Kill "TESTFILE" line.  Program control ignores the error handler routine.  The code I use in my applications is very similiar to the OnErrorStatementDemo shown below.  Neither of them work.  Am I doing something wrong or has the Add-On somehow affected my system?
Sub OnErrorStatementDemo()
  Dim objectref As Object
  Dim msg As String
   On Error GoTo ErrorHandler   ' Enable error-handling routine.
   Open "TESTFILE" For Output As #1   ' Open file for output.
   Kill "TESTFILE"   ' Attempt to delete open
            ' file.
   On Error GoTo 0   ' Turn off error trapping.
   On Error Resume Next   ' Defer error trapping.
   objectref = GetObject("MyWord.Basic")   ' Try to start nonexistent
            ' object, then test for
'Check for likely Automation errors.
   If Err.Number = 440 Or Err.Number = 432 Then
      ' Tell user what happened. Then clear the Err object.
      msg = "There was an error attempting to open the Automation object!"
      MsgBox msg, , "Deferred Error Test"
      Err.Clear   ' Clear Err object fields
   End If
Exit Sub      ' Exit to avoid handler.
ErrorHandler:   ' Error-handling routine.
   Select Case Err.Number   ' Evaluate error number.
      Case 55   ' "File already open" error.
         Close #1   ' Close open file.
      Case Else
         ' Handle other situations here...
   End Select
   Resume   ' Resume execution at same line
            ' that caused the error.
End Sub

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

did you try to add a breakpoint to check if the error handler works?
2topAuthor Commented:
Thanks for your response!  Yes, I stopped on the On Error statement and stepped the next two statements.  It errs on the Kill statement but never goes to the ErrorHandler routine.
maybe you have turned on break on all error

IDE Options
These options only work when your program is running in the IDE. They have no bearing on your compiled code. To select the required option from the IDE main menu select Tools, Options & then the General tab. There are 3 options to handle Error Trapping.

Break On All Errors
Tells your application to stop execution at the point of the error, even if you have coded an error handling routine. Generally you will use this option if you are trying to track down a specific error.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
2topAuthor Commented:
I didn't fully understand the options on the General tab.  It seemed to me that Break on all Errors was correct.  It was set that way and I changed it to Break on Unhandled Errors and now my Error Handling works!  Thank you!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.