I can not enter interrupt mode at this time

This happens more often when I have sheet.add or sheets.delete in excel VBA. After searching and searching, I finally found the official Microsoft support page on it. My question is: does anyone know why I could step over this code just fine again and again, and then suddenly starts to do what Microsoft says it will always do, and is there any way to fix it?

Sub foo()

    Sheets.add
    debug.print "sheet added" 'breakpoint here

End sub

It is so simple. You cannot recreate it, because the problem I am asking is that this does not happen at first. It works great time and time again, and then randomly presents the error described in the linked Microsoft support page.

+2
source share
3 answers

Here are some suggestions that are not perfect,

First, make sure no error occurs if a breakpoint is not set.

If not, try a few more things:

  • From the Debug VBE "Compile VBA Project" menu, it's worth taking a picture.
  • Delete the entire row. Run the code. Then return the line and try again with a breakpoint.
  • Add statement DoEventsafterSheets.Add
  • MsgBox Debug.Print. , ctrl + fn + End. ( "" , , )
  • Sheets.Add; Print, .
  • ? , , , , .
0

Excel/VBA.

, :

  • VBE,
  • , ,
  • , ,
  • , , (SHIFT F8), (F5).

.

, , .

0

, Microsoft Visual Basic . :

Excel , , :

A program change was made to the project using the object model of extensibility (add-in). This prevents the program from pausing. You can continue execution or end execution, but cannot pause execution .

You cannot step through the code when making changes to the project (dynamically, for example, using InsertLine, etc.). code can be run, but not step by step.

0
source

Source: https://habr.com/ru/post/1650046/


All Articles