How to Stop VBA from executing

H

hon123456

Dear all,

I have write VBA Code to close a workbook when it was open.
Now when I open the workbook, the workbook will close immediately, thus
I cannot edit the VBA Code. How can stop the VBA code from executing
and then I can edit the VBA code.

Thanks.
 
N

Nigel

Select disable macros on opening Excel.

If this does not appear open Excel and set security to medium, then close
Excel and open your problem workbook, then select disable macros.
 
G

Guest

My impression is it was an autoopen macro. Depending on how long it takes
the macro to run, I think there may not be enough time.

Personally, I keep a button on my toolbar to toggle events on/off
Sub ToggleEvents()
With Application
.EnableEvents = Not .EnableEvents
If .EnableEvents Then
.StatusBar = False
Else: .StatusBar = "Events Are Disabled"
End If
End With
End Sub

But the OP could also set security to medium or high prior to opening the
workbook.
 
T

thesquirrel

I have had this problem as well recently and I solved it by doing
this...

debug.assert 1 = 2

Adding this as the first line in your Auto_Open and it will break on
its own each time its run.

Hope that helps.

theSquirrel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top