Sign in with Microsoft
Sign in or create an account.
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

A common feature of integrated development environments is the ability to debug, or find and fix errors in, script that you have written. When you debug script, you can either debug when a script error occurs or set a breakpoint by adding a debug statement to the script. A debug statement tells the debugger when to suspend execution and allow you to step through your script and examine its behavior. This article explains how to add a debug statement to a script.

  1. In Microsoft Office InfoPath, open the form template that contains the script.

  2. On the Tools menu, point to Programming, and then click Microsoft Script Editor, or press ALT+SHIFT+F11 to open Microsoft Script Editor (MSE).

  3. In the script, place the cursor where you want to add a debug statement, and then do one of the following:

    • To add a debug statement in the Microsoft JScript scripting language, type the debugger; statement.

  • To add a debug statement in the Microsoft Visual Basic Scripting Edition (VBScript) scripting language, type the Stop statement.

  1. The following example demonstrates how to use the debug statement in the OnLoad event handler by using JScript syntax:

    function XDocument::OnLoad(eventObj)
  2. Click Save in MSE, or press CTRL+S.

  3. Switch to InfoPath.

  4. On the Standard toolbar, click Preview, or press CTRL+SHIFT+B.

  5. In the Just-In-Time Debugging dialog box, click New Instance of Microsoft Script Editor, and then click Yes.

  6. In the Step Into Remote Procedure Call dialog box, click Script, and then click OK. MSE opens in debug mode and a yellow arrow indicates where execution was suspended.

    Tip: With MSE in debug mode, you can use all of the debugging features that it provides. This includes setting breakpoints, stepping through program statements, and viewing any of the debugging windows such as the Watch, Immediate, and Call Stack windows.

  7. If you want to stop debugging your script, click Stop Debugging on the Debug menu, or press SHIFT+F5 in MSE.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Was this information helpful?

What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!