As you saw in the previous article, it's easy to build a custom worksheet function for Excel with JetXLL. Of course, whilst you are developing your worksheet functions you may make mistakes and wish to debug the code whilst it is running inside Excel; luckily this too is very easy!
- Open the SimpleAddin solution file, select the solution explorer tab and select the solution.
- Right click and select properties.
- Select the Debug tab and check the 'start external program' button.
- Browse for the Excel executable (usually located at Program Files\Microsoft Office\Office12\Excel.exe).
- Build the addin and copy the JetXLL.xll file and JetXLL.xml file into the same directory as the addin's dll file that you have just built.
- Start debugging and Excel will start up; you may get a warning about Excel not containing debugging information, you can ignore this.
- Place a breakpoint in your addin.
- Within Excel select File, Open and browse to the directory where you built your addin, select the JetXLL.xll file and open it. This will load JetXLL and your addin into Excel.
- Enter your worksheet function into a cell and when the cell is calculated you will find yourself in the debugger inside your worksheet function.
You may want to set up Excel so that you always load JetXLL and your addins, a future article will show you how to do this. If you set Excel up in this way then debugging is even easier, as soon as Excel is loaded by the debugger it will load JetXLL and your addin and you can simply load a test sheet and step into your functions.
Leave a comment