RE: Stop the Debug option from coming up



Thank you,

The Exit sub as suggested by Mike and Stefi fixed the problem.

"Joel" wrote:

First there is an error someplace else in the code. That is why the debug
error messagge is showing up. I would recommend finding and fixing this
problem.

You can add On Error

On Error GoTo line

On Error Resume Next

On Error GoTo 0
------------------------------------------------------------------------------
Sub OnErrorStatementDemo()
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




"sus1e" wrote:

I have a code which asks the user to input a password before it will continue
with the code. If the password is incorrect it puts up a message box which
informs the user. At this point, I get the microsoft error message which
gives the user the option to debug............ I don't want this to occur.

Is there any way I can stop the microsoft error message from coming up?

My current code looks like:

Dim MyStr1 As String, MyStr2 As String
MyStr2 = ("admin") 'This is the password and it is CASE sensitive
MyStr1 = InputBox("Password Required")
If MyStr1 = MyStr2 Then
Active***.Unprotect Password:=MyStr1
Else
MsgBox ("Access Denied")
End If

Rest of code.....................

Thanks in advance.
.