Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save as .xla option is not coming when I try to save Parag Excel Discussion (Misc queries) 3 January 28th 09 06:28 AM
How to stop Option Button unselecting one on different worksheet? nesmith6866 Excel Discussion (Misc queries) 1 December 14th 06 12:49 AM
stop all the columns coming up the same length in a chart prinshin Charts and Charting in Excel 1 April 21st 06 10:38 AM
VBE Options: Disabling Debug Option on All Errors JGS Excel Programming 1 December 4th 05 10:05 PM
VBA Crashes Excel on Compile or Stop Debug Frank & Pam Hayes[_2_] Excel Programming 0 June 24th 04 09:52 PM


All times are GMT +1. The time now is 03:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"