Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1392
  • Last Modified:

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

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
macbone2
Asked:
macbone2
  • 7
  • 5
  • 2
  • +1
1 Solution
 
Richie_SimonettiIT OperationsCommented:
Humm, try to see is there is time problem. Run your macros with F8 and see...
0
 
macbone2Author Commented:
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
 
Richie_SimonettiIT OperationsCommented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
macbone2Author Commented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
macbone2Author Commented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
macbone2Author Commented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
macbone2Author Commented:
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
 
Richie_SimonettiIT OperationsCommented:
OK. I am working at.
Happy Vacations!
0
 
bruintjeCommented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
bruintjeCommented:
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
 
NetminderCommented:
Per recommendation, points refunded and question closed.

Netminder
EE Admin
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now