EntropyPilot

In an Excel project, how can the open workbook be viewed after a debug breakpoint is encountered

I am new to VSTO and just trying to get my feet wet. I have created a button in an excel worksheet which executes code which reads numbers from a few cells, performs a math operation on the values and wirtes the result to another cell. The code executes fine. But if I insert a breakpoint, I cannot view the worksheet again until the execution is resumed and completed.

I have searched MSDN and this forum for answers without success. I would apprecate any comments.

Thanks.



Re: Visual Studio Tools for Office How to view Excel worksheet after debug breakpoint encounter?

Toby Russell

Hi,

Unfortunately you will tend to find that if you are running in debug mode you will get blank screens in Office after you hit a breakpoint until you hit F5 again. This has been my experience with Excel, I don't think there's anything you can do about it. You may be able to view variables in your debug window, but you won't see what's in Excel.

Sorry I couldn't be more helpful.

Regards,

Toby






Re: Visual Studio Tools for Office How to view Excel worksheet after debug breakpoint encounter?

EntropyPilot

Thanks for your response Toby.

The blank workbook screen continues until the code behind the Button has finished execution. If I don't insert a breakpoint, the Excel screen update is controlled by the code initiated by the button click. My test code initially executes application.screenupdate = false and periodically executes application.screenupdate = false followed by application.screenupdate = true to update the screen. After a a breakpoint encounter, the Excel screen is totally blank until the Button code is allowed to completely finsh execution.

What I really want to do is use Excel as my user interface for a Visual Basic program. But when I stop exection with a breakpoint, the ability to view the Excel workbook is lost until the code is completely executed. This makes it very difficult to debug the VB code. Also, in debug mode, if stepping through VB code executes actions involving changes to the workbook, the workbook actions build up in a stack since the workbook is not accessible until the Button code finshes executing. Eventually either a stack overflow error or a timeout condition occurs.

Anyway, it doesn't look like VSTO is a tool that will be very useful for me unless I can figure out a way to keep the workbook live while in debug mode. I am afraid I may need to investigate opening another workbook in a seperate thread to use as my main program user interface.

Thanks agian for your comments.





Re: Visual Studio Tools for Office How to view Excel worksheet after debug breakpoint encounter?

Cindy Meister

I sympathize. Annoys the heck out of me, as well. But I've learned to work around it.

You might consider changing your debugging technique. Comment out the "bottom half" of your code so that execution actually stops at the point where you want to look at the result. If that's fine, uncomment a few more lines, and so on, until you've located the problem point.

You can certainly get along without VSTO, but in order to have controls on a sheet you'd have to work with VBA or COM ActiveX controls. Use the ISmartDocument interface to get a document-specific task pane. But all of that is a lot more work (= longer development time) than using VSTO, even if you have to debug in a different manner than to what you're accustomed.