How do you debug on start up?

reneuend

Board Regular
Joined
May 20, 2009
Messages
155
I need to be able to debug an error that occurs when the workbook first opens. The problem is that I don't get an option to "debug". Is there a way to stop the code in my macro when the workbook first opens?

I tried using "stop", but it treated it like a comment and went right past it.

- Excel 2003
- Windows XP

All comments are very much appreciated!
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi Smitty,

Thanks for the reply.

I'm not able to post the code due to corporate policy, but the error I'm receiving is a "Runtime Error 1004: Application-Defined or Object-Defined Error" when I first open the workbook. There is a lot of code that runs upon opening the workbook, but this error started occuring when I integrated some worksheets from another workbook that had numerous named references. I had to go through the named references and change their locations to use this workbook. I also removed a lot of dead named references while I was at it. I'm guessing that maybe there is a call to a named-reference that no longer exists.

If there was a way to stop the code when it first opens the workbook so I can go into debug mode, then I could step through it and find where the issue is occuring. Do you know a way to do this?


(edit) I used "On Error" routine to try to bypass the error when the error was a 1004, but I feel like this might come back to bite me later.




Thanks!
 
Last edited:
Upvote 0
Fortunately, you can actually step through the Open event. Just use F8 and that will walk you through the code line-by-line.
 
Upvote 0
I figured it out. My call to "stop" in the workbook_open routine wasn't working because I had the vba code password protected. Once I turned off the protection, I was able to stop the code upon opening the workbook and step to where the error occurred.

Thanks for spending time with me, Smiitty. Much appreciated.
 
Upvote 0

Forum statistics

Threads
1,224,561
Messages
6,179,521
Members
452,923
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top