Solved

'Can't enter break mode at this time'  Can this dialog be trapped in VBA

Posted on 2002-07-03
15
1,345 Views
Last Modified: 2012-05-07
Is there a way to trap the VBA error message 'Can't enter break mode at this time' when running a VBA macro. A dialog box is displayed which require entry of Continue, End etc from a user. Can this be trapped by VBA? For the moment, I don't care why it's happening, as I've found that taking the Continue option allows the process to go through to end. What I want to do is trap it and branch round it, until I can fix the cause, so that the user is not aware of it happening.  'On error'  doesn't detect the problem.

0
Comment
Question by:macbone2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 2
  • +1
15 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7130388
Humm, try to see is there is time problem. Run your macros with F8 and see...
0
 
LVL 2

Author Comment

by:macbone2
ID: 7130706
Richie, thanks but I've stepped thru these macros with F8 many times, and when the crucial line is encountered, the 'Can't enter break mode...' message occurs. I can't trap or control it. even Stop doesn't have any effect.
I don't understand the reference to time problem.

macbone2
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7130726
Some times methods and functions are called asyncronius so they return to caller without finish the task yet. Then, when you try to use the resulting data (or whatever you use) that data isn't available yet. Due to that i did think it was a time problem.
Could you post the code here?
0
Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 
LVL 2

Author Comment

by:macbone2
ID: 7131505
RICHIE
Thanks for taking the time. The code is below, it's all straight forward stuff that I've used before. There seems to be something odd about this workbook. I took the book over and rebuilt it, and added masses of VBA. Odd things were happening with it like Application.ScreenUpdating = False had no effect.
When I looked at Addins, Solver was there, and I wondered if that was a problem, so removed it. Made no diff but wonder if nasties left behind??

 In the code below, if I comment out the first line that causes the break mode message, the next line cause it. Even if the 'Sheets("Week 1").Move'   code
is executed on its own, the message is displayed. Sorry this is so long. BTW I've tried moving the essential sheets and VBA to a new book, but when I try to reopen it, I get an application error 'Access violation' (I tried this 3 times)


Sub SaveWeek2()
Dim FILEWeek1 As String, FldrName As String
ActiveSheet.Unprotect password:="jen"
Application.DisplayAlerts = False
Application.EnableEvents = False
Sheets("Week 1").Select
On Error Resume Next
'* Get rid of all the buttons,combo boxes etc
ActiveSheet.Shapes.SelectAll
Selection.Cut   '** THIS LINE CAUSES 'Can't enter break mode...
On Error Resume Next
'* Delete event handlers from Week 1 sheet
'this identifies the sheet code and deletes
Call DeleteCtlVBA    '** THIS ROUTINE CAUSES 'Can't enter break mode...
'* move the sheet to a new book and save
On Error Resume Next
Sheets("Week 1").Move   '** THIS LINE CAUSES 'Can't enter break mode...
FILEWeek1 = Range("HtlName") & " FORECAST " & _
Format(Range("c1").Value, "YYYY-MM-DD")
Stop
FldrName = "C:\Forec938\"
On Error Resume Next
MkDir FldrName
Stop
FILEWeek1 = FldrName & FILEWeek1
    On Error Resume Next
    ActiveWorkbook.SaveAs FILEWeek1
    If Err.Number <> 0 Then
    MsgBox "Error " & Err.Number & Chr(13) & "Description  " & Err.Description
    End If
ActiveWorkbook.Close
End Sub
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7131892
Well, i don't get that error.
Could you try this?
Sub SaveWeek2()
dim sh as worksheet
Dim FILEWeek1 As String, FldrName As String

set sh= thisworkbook.sheets("Week 1")
with sh
     .Unprotect password:="jen"
     Application.DisplayAlerts = False
     Application.EnableEvents = False
On Error Resume Next
'* Get rid of all the buttons,combo boxes etc
     .Shapes.SelectAll
end with
     Selection.Cut   '** THIS LINE CAUSES 'Can't enter break mode...
...
....
0
 
LVL 2

Author Comment

by:macbone2
ID: 7132216
Richie, No, I don't get the error in any other workbook either. This is the only place I've encountered it.
I tried the alternative code you kindly provided, but it makes no difference, at the line    'Selection.Cut'     the message still occurs.

0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7132464
Well, i think that i know what happens here.
Before do any deletion of controls and code, save the resultant file. After that remove not wanted controls and code from that file and save it again.
It appears like we are trying to delete objects and code that are use at the time of deletion.
0
 
LVL 2

Author Comment

by:macbone2
ID: 7137507
Hi Richie, Thanks for the suggestion, I've tried all combinations of moving, copying or deleting sheets, controls and VBA code combined with saving before. In every case I always at some point come across the stumbling block of the warning message, so now i HAVE TO find a way of trapping the message, and forcing the macro to continue. Any ideas?

Thanks again for your time

Geoff
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7144190
Well, we could manage a test.
I could do a little workbook trying to do what i already explained: would you like that i send it to you?
0
 
LVL 2

Author Comment

by:macbone2
ID: 7144903
Yes that might be helpful Richie. My email address is geoff.mckeown@gordona.demon.co.uk.
One small problem is that I go on vacation tomorrow (Thursday) early, and won't be back until 31 July, but please post it and i will respond ASAP

Thanks
Geoff
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7146112
OK. I am working at.
Happy Vacations!
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7400567
Hi guys any chance of getting this back on track? Haven't seen you for a long while Richie ...!... you didn't give up on EE i hope :)
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7401502
Hi Bruintje! I have been very very busy for the pass month and just right know, i am working on an external project ($). No time to post "free" work as you could imagine.
Cheers
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7456762
Hello macbone2

this question is open for more then 2 months
time to clean up
if not stated otherwise

my recommendation will be
-PAQ and refund
-this will be finalized by an EE Moderator
-with no further update (23.11.2002)

PLEASE DO NOT ACCEPT THIS COMMENT AS ANSWER

HAGD:O)Bruintje
posted by ToolzEE v1.0
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 7488937
Per recommendation, points refunded and question closed.

Netminder
EE Admin
0

Featured Post

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question