PC Review


Reply
Thread Tools Rate Thread

ctrl+break when modeless

 
 
hughie
Guest
Posts: n/a
 
      3rd Jan 2007
How does one break out into the code when a modeless userform is
running. When I had it running modal, I would go Ctrl+break and it
would open the editor. Anyone?

tia,
Hughie

 
Reply With Quote
 
 
 
 
hughie
Guest
Posts: n/a
 
      3rd Jan 2007

Mike wrote:

> In modal operation all code execution stops until the userform finishes
> compared to non modal where other code (except other user forms) can continue
> to execute. Pressing ctrl/break in non modal is therefore unlikely to break
> into the userform code.


I see. How does one then continue to work on the code and develop the
app? I open the spreadsheet, it automatically starts my form and now I
can't get at the code.

Hughie

 
Reply With Quote
 
jeff.j.griffith@gmail.com
Guest
Posts: n/a
 
      3rd Jan 2007
Put this line:

Debug.Assert False

wherever you want your code to break. It's the rough equivalent of a
programmatic breakpoint.


hughie wrote:
> Mike wrote:
>
> > In modal operation all code execution stops until the userform finishes
> > compared to non modal where other code (except other user forms) can continue
> > to execute. Pressing ctrl/break in non modal is therefore unlikely to break
> > into the userform code.

>
> I see. How does one then continue to work on the code and develop the
> app? I open the spreadsheet, it automatically starts my form and now I
> can't get at the code.
>
> Hughie


 
Reply With Quote
 
hughie
Guest
Posts: n/a
 
      3rd Jan 2007

jeff.j.griff...@gmail.com wrote:

> Put this line:
>
> Debug.Assert False
>
> wherever you want your code to break. It's the rough equivalent of a
> programmatic breakpoint.


Because I can't get to the code I can't add the line!

H

 
Reply With Quote
 
jeff.j.griffith@gmail.com
Guest
Posts: n/a
 
      3rd Jan 2007
Or click anywhere on your worksheet and press Alt + F11. Then add the
line I told you to and re-open your worksheet.


hughie wrote:
> jeff.j.griff...@gmail.com wrote:
>
> > Put this line:
> >
> > Debug.Assert False
> >
> > wherever you want your code to break. It's the rough equivalent of a
> > programmatic breakpoint.

>
> Because I can't get to the code I can't add the line!
>
> H


 
Reply With Quote
 
hughie
Guest
Posts: n/a
 
      3rd Jan 2007

Mike wrote:

> Access the code by using the VB editor (Tools - Macro - VB Editor). If the
> userform hasn't terminated its a good idea to do this first


When I terminate the userform it closes the whole spreadsheet therefore
I can't get to the editor that way unfortunately. I can open the
editor when I start excel without opening any specific spreadsheet but
then my code is, of course, unavailable as I don't have my xls open.
See what I mean?

This has GOT to be an easy one.... I thought....hehe

 
Reply With Quote
 
hughie
Guest
Posts: n/a
 
      3rd Jan 2007

hughie wrote:

> Mike wrote:
>
> > Access the code by using the VB editor (Tools - Macro - VB Editor). If the
> > userform hasn't terminated its a good idea to do this first

>
> When I terminate the userform it closes the whole spreadsheet therefore
> I can't get to the editor that way unfortunately. I can open the
> editor when I start excel without opening any specific spreadsheet but
> then my code is, of course, unavailable as I don't have my xls open.
> See what I mean?
>
> This has GOT to be an easy one.... I thought....hehe


the version of the code i was using before, the one that was running
the form modally, was doing an 'application.visible = false', so users
only see the form. Although there is a way to get to were I want by
taking that version forward, I'm now curious to know if there is a way
to get to the code in this situation.

Just to clarify, I can't get to the editor, or the spreadsheet and
ctrl+break is no longer available. The previous suggestions are
welcome but off the mark.

curious..


H !?

 
Reply With Quote
 
Helmut Weber
Guest
Posts: n/a
 
      3rd Jan 2007
Heh...

so you've definitely locked yourself out?

Is there no way in Excel to open a file
without auto-macros running like in Word.
Something like holding shift or control
or some other key pressed while opening the file.
Called, I think, secure mode.

If there is absolutely no other way,
I'd try to put an error in the code
by opening the workbook in an hex-editor
and change just one letter in a reserved word in the code.
That is change, not add or delete.

I wonder.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      3rd Jan 2007
hold the shift key as you launch excel and see if that works. else

start excel in safe mode. add /s to the end of the shortcut that starts excel
and then change it back when you're done

--


Gary


"hughie" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> hughie wrote:
>
>> Mike wrote:
>>
>> > Access the code by using the VB editor (Tools - Macro - VB Editor). If the
>> > userform hasn't terminated its a good idea to do this first

>>
>> When I terminate the userform it closes the whole spreadsheet therefore
>> I can't get to the editor that way unfortunately. I can open the
>> editor when I start excel without opening any specific spreadsheet but
>> then my code is, of course, unavailable as I don't have my xls open.
>> See what I mean?
>>
>> This has GOT to be an easy one.... I thought....hehe

>
> the version of the code i was using before, the one that was running
> the form modally, was doing an 'application.visible = false', so users
> only see the form. Although there is a way to get to were I want by
> taking that version forward, I'm now curious to know if there is a way
> to get to the code in this situation.
>
> Just to clarify, I can't get to the editor, or the spreadsheet and
> ctrl+break is no longer available. The previous suggestions are
> welcome but off the mark.
>
> curious..
>
>
> H !?
>



 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      3rd Jan 2007
If your form automatically loads when Excel (or the particular workbook)
opens, you need to prevent that from happening if you want to edit your
code. When you open the workbook, hold down the SHIFT key. That will prevent
workbook startup code from running. Now you'll have your workbook open but
will not have the start up form visible. Edit your code normally.

I don't think you can trap the CTRL+BREAK key if the procedure that shows
the form terminates. CTRL+BREAK doesn't make it through to the usual
KeyPress, KeyUp, and KeyDown events of the UserForm object. One way to do it
would be to rewrite the procedure that displays the form as follows:

Sub ShowTheForm()
Dim N As Long '<< Test only. Remove.
Dim Done As Boolean
Const BREAK_KEY_PRESSED = 18

On Error GoTo BreakKeyHandler:
'''''''''''''''''''''''''''''''''''''''''''''
' Configure EnableCancelKey to raise an error
' 18 when the user types CTRL+BREAK.
'''''''''''''''''''''''''''''''''''''''''''''
Application.EnableCancelKey = xlErrorHandler
'''''''''''''''''''''''''''''''''''''''''''''
' Show The Form modelessly
'''''''''''''''''''''''''''''''''''''''''''''
UserForm1.Show vbModeless
'''''''''''''''''''''''''''''''''''''''''''''
' Loop doing nothing. Worksheet and form
' events will continue to work as expected.
'''''''''''''''''''''''''''''''''''''''''''''
Done = False
Do Until Done = True
N = N + 1 ' <<< Testing: Omit this line
DoEvents ' Release to other threads
Loop
''''''''''''''''''''''
' Get out.
''''''''''''''''''''''
Exit Sub
BreakKeyHandler:
Done = True
''''''''''''''''''''''''''''''''''''''''''
' If the user pressed CTRL+BREAK, VBA will
' raise an error 18.
''''''''''''''''''''''''''''''''''''''''''
If Err.Number = BREAK_KEY_PRESSED Then
''''''''''''''''''''''''''''''''''''''
' User type CTRL+BREAK. Hide the
' form.
''''''''''''''''''''''''''''''''''''''
MsgBox "User typed CTRL+BREAK" '<<< Testing Only. Remove
UserForm1.Hide
' Unload UserForm1
Exit Sub
Else
'''''''''''''''''''''''''''''''''''''
' Some other error occurred.
'''''''''''''''''''''''''''''''''''''
MsgBox "An unexpected error occurred: " & _
CStr(Err.Number) & " Description: " & Err.Description
End If

End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"hughie" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> hughie wrote:
>
>> Mike wrote:
>>
>> > Access the code by using the VB editor (Tools - Macro - VB Editor). If
>> > the
>> > userform hasn't terminated its a good idea to do this first

>>
>> When I terminate the userform it closes the whole spreadsheet therefore
>> I can't get to the editor that way unfortunately. I can open the
>> editor when I start excel without opening any specific spreadsheet but
>> then my code is, of course, unavailable as I don't have my xls open.
>> See what I mean?
>>
>> This has GOT to be an easy one.... I thought....hehe

>
> the version of the code i was using before, the one that was running
> the form modally, was doing an 'application.visible = false', so users
> only see the form. Although there is a way to get to were I want by
> taking that version forward, I'm now curious to know if there is a way
> to get to the code in this situation.
>
> Just to clarify, I can't get to the editor, or the spreadsheet and
> ctrl+break is no longer available. The previous suggestions are
> welcome but off the mark.
>
> curious..
>
>
> H !?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
CTRL-BREAK Mac Gil Microsoft Excel Programming 1 29th Jul 2007 04:36 AM
CTRL+C doesn't terminate ANYTHING, only CTRL+BREAK works. dbareis [Windows Installer MVP] Microsoft Windows 2000 CMD Promt 4 11th Apr 2007 08:33 AM
Ctrl+Alt+Break Tom Microsoft Excel Programming 0 13th Apr 2005 12:22 PM
Can Not Get Macro to Break with CTRL-BREAK =?Utf-8?B?QnJlYWsgTWU/?= Microsoft Excel Programming 0 8th Sep 2004 03:15 AM
Ctrl + Break =?Utf-8?B?V2lsbA==?= Microsoft VB .NET 1 2nd Feb 2004 05:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:52 AM.