none
Breakpoint in Open Routine RRS feed

  • Question

  • Hi

    Is it possible to set a breakpoint (or something similar) in the Workbook Open event - so that when I open the workbook the execution stops and I can monitor what is happening?

    many thanks,

    peter

    Tuesday, August 30, 2016 9:45 AM

Answers

  • Hello Peter

    Just enter Stop in the Workbook Open event at the point where you want to halt the code, save it, and when you reopen the workbook it will open the VBE and stop the code at that point.

    Hope this helps

    Andy C

    • Marked as answer by py1 Tuesday, August 30, 2016 11:18 AM
    Tuesday, August 30, 2016 10:43 AM
  • Andy

    Weird  - extract below , but does not work. thanks for your help, much appreciated.

    Private Sub Workbook_Open()


    Stop

    MsgBox "after stop"

        ' Unprotect the workbook
        ThisWorkbook.Unprotect
       
        ' Build the change selection fields from the current view
        Call BuildViewFields

    • Marked as answer by py1 Tuesday, August 30, 2016 11:18 AM
    Tuesday, August 30, 2016 11:18 AM
  • Peter, a further thought.  Make sure that Events are enabled.  In the immediate window Type:

    Application.EnableEvents = true

    Andy

    • Marked as answer by py1 Tuesday, August 30, 2016 11:22 AM
    Tuesday, August 30, 2016 11:20 AM

All replies

  • Hello Peter

    Just enter Stop in the Workbook Open event at the point where you want to halt the code, save it, and when you reopen the workbook it will open the VBE and stop the code at that point.

    Hope this helps

    Andy C

    • Marked as answer by py1 Tuesday, August 30, 2016 11:18 AM
    Tuesday, August 30, 2016 10:43 AM
  • Hi Andy

    I did enter Stop as the first statement in the Open Workbook statement but  it did not stop?

    I entered a msgbox statement after the stop command and it executed that?

    my workbook is password protected - could it be that somehow that does not make this work? I am grasping at straws a bit here - but any thoughts you have would be appreciated. 

    many thanks

    Peter

    Tuesday, August 30, 2016 10:54 AM
  • Hi Peter

    I have just tried using Stop in a password protected workbook, and the code stopped at the Stop command in the Open event.  Confirm that you have entered "Stop" after the opening line in the "This Workbook" object:

    Private Sub Workbook_Open()

    Stop

    Code ......

    End Sub

    Andy C

     

    Tuesday, August 30, 2016 11:11 AM
  • Andy

    Weird  - extract below , but does not work. thanks for your help, much appreciated.

    Private Sub Workbook_Open()


    Stop

    MsgBox "after stop"

        ' Unprotect the workbook
        ThisWorkbook.Unprotect
       
        ' Build the change selection fields from the current view
        Call BuildViewFields

    • Marked as answer by py1 Tuesday, August 30, 2016 11:18 AM
    Tuesday, August 30, 2016 11:18 AM
  • Peter, a further thought.  Make sure that Events are enabled.  In the immediate window Type:

    Application.EnableEvents = true

    Andy

    • Marked as answer by py1 Tuesday, August 30, 2016 11:22 AM
    Tuesday, August 30, 2016 11:20 AM
  • thanks Andy - will do.
    Tuesday, August 30, 2016 11:23 AM