RE: Stop the Debug option from coming up
- From: Joel <Joel@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 5 Oct 2007 04:44:01 -0700
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.
- Follow-Ups:
- RE: Stop the Debug option from coming up
- From: sus1e
- RE: Stop the Debug option from coming up
- Prev by Date: Re: Speed of Execution
- Next by Date: Get names of all workbooks in a directory
- Previous by thread: Debugging Help
- Next by thread: RE: Stop the Debug option from coming up
- Index(es):