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!
 

Some videos you may like

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

reneuend

Board Regular
Joined
May 20, 2009
Messages
155
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:

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Fortunately, you can actually step through the Open event. Just use F8 and that will walk you through the code line-by-line.
 

reneuend

Board Regular
Joined
May 20, 2009
Messages
155
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.
 

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
Sorry, I should have asked if you had protected the project.
 

Watch MrExcel Video

Forum statistics

Threads
1,127,405
Messages
5,624,574
Members
416,036
Latest member
eloisa manzanarez

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
Top