Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Stop the Debug option from coming up
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 ActiveSheet.Unprotect Password:=MyStr1 Else MsgBox ("Access Denied") End If Rest of code..................... Thanks in advance. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Stop the Debug option from coming up
The code you have posted shouldn't cause the debug option window to pop up so
it must be some other part of the code after the endif so try this small change:- Sub Sonic() 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 ActiveSheet.Unprotect Password:=MyStr1 Else MsgBox ("Access Denied") Exit Sub End If End Sub Mike "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 ActiveSheet.Unprotect Password:=MyStr1 Else MsgBox ("Access Denied") End If Rest of code..................... Thanks in advance. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Stop the Debug option from coming up
Put an
Exit Sub or an Application.Quit line after MsgBox! Regards, Stefi €žsus1e€ť ezt Ă*rta: 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 ActiveSheet.Unprotect Password:=MyStr1 Else MsgBox ("Access Denied") End If Rest of code..................... Thanks in advance. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Stop the Debug option from coming up
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 ActiveSheet.Unprotect Password:=MyStr1 Else MsgBox ("Access Denied") End If Rest of code..................... Thanks in advance. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Stop the Debug option from coming up
That worked wonderfully, thank you.............
All I needed was the Exit sub bit! "Mike H" wrote: The code you have posted shouldn't cause the debug option window to pop up so it must be some other part of the code after the endif so try this small change:- Sub Sonic() 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 ActiveSheet.Unprotect Password:=MyStr1 Else MsgBox ("Access Denied") Exit Sub End If End Sub Mike "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 ActiveSheet.Unprotect Password:=MyStr1 Else MsgBox ("Access Denied") End If Rest of code..................... Thanks in advance. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Stop the Debug option from coming up
Thank you very much - Its now working fine.
"Stefi" wrote: Put an Exit Sub or an Application.Quit line after MsgBox! Regards, Stefi €žsus1e€ť ezt Ă*rta: 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 ActiveSheet.Unprotect Password:=MyStr1 Else MsgBox ("Access Denied") End If Rest of code..................... Thanks in advance. |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 ActiveSheet.Unprotect Password:=MyStr1 Else MsgBox ("Access Denied") End If Rest of code..................... Thanks in advance. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Save as .xla option is not coming when I try to save | Excel Discussion (Misc queries) | |||
How to stop Option Button unselecting one on different worksheet? | Excel Discussion (Misc queries) | |||
stop all the columns coming up the same length in a chart | Charts and Charting in Excel | |||
VBE Options: Disabling Debug Option on All Errors | Excel Programming | |||
VBA Crashes Excel on Compile or Stop Debug | Excel Programming |