Script Debugging Tools

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The Microsoft Script Debugger provides a comprehensive debugging environment for working with both client- and server-side script in HTML pages and Active Server Pages (ASP). The Script Debugger works with Microsoft® Visual Basic® Scripting Edition (VBScript) and Microsoft® JScript®. It provides all of the run-time debugging tools provided by VBA, with the exception of watch expressions. However, you cannot use the Print method of the Debug object to output information to the Script Debugger's Immediate window.

The Microsoft Script Debugger and its supporting documentation are available from the Microsoft Scripting Technologies Web site at http://www.microsoft.com/technet/scriptcenter/guide/default.mspx?mfr=true.

You can debug the script you add to a Microsoft® Office document by using the debugging capabilities of the Microsoft Script Editor.

To enable script debugging in the Script Editor, click Options on the Tools menu, and then click Debugger in the hierarchical view of options. Select the Just-In-Time debugger and Attach to programs running on this machine check boxes. When these options have been selected, errors in script will generate a message box that gives you the option of opening the Script Editor's debugger.

You can use the Script Editor to set breakpoints in your script. These breakpoints work just as they do when you are debugging VBA code in the Visual Basic Editor. The Script Editor also has the following debugging windows that you can use to work with script: Immediate, Locals, Watch, Threads, and Call Stack. These windows give you views into your running script in the same way that they let you debug VBA code when they are used in the Visual Basic Editor. There is one difference you must be aware of however. In the Script Editor, the script debugger is not as tightly integrated with the host application as the VBA debugger is in Office applications. This means that the Immediate and Watch windows in the Script Editor are not active unless your script is stopped at a breakpoint. In other words, you cannot set up a Watch variable in the Script Editor and watch its value change as your script executes.

You should remember to close the script debugger each time you are finished debugging or each time you return to running your script. This is because each time you open the debugger, a new instance of the Script Editor is created. If you do not close these instances, you can end up with several open windows on your desktop. To avoid opening and closing the script debugger, you can create a debug log file to record errors that occur on a page while a script is running. You can also open a separate window to display the logged error information.

See Also

Writing Error-Free Code | Design-Time Tools | Run-Time Tools | Additional Debugging Techniques | Handling Errors | Using Web Technologies | Working with Office Applications