Working with Scriptlets

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 document object model supports a data-binding architecture that makes it possible for you to programmatically sort or filter data displayed on the page without requiring additional trips to the server. The document object model also supports Microsoft Scripting Components (scriptlets), which are lightweight, reusable objects that encapsulate code or a user-interface component. Scriptlets are created by using HTML code and script (either Microsoft® Visual Basic® Scripting Edition [VBScript] or Microsoft® JScript®).

To add script to a Microsoft® Office document, you use the Microsoft Script Editor. To open the Script Editor from inside an Office document, point to Macro on the Tools menu, and then click Microsoft Script Editor.

VBScript vs. JScript

Although Microsoft® Internet Explorer supports the use of VBScript code, JScript code, or both in a Web page, these Help topics focus primarily on working with VBScript code for two reasons:

  • VBScript is a subset of Visual Basic for Applications (VBA), which means that you already know how to use this scripting language because of your familiarity with VBA. In many cases, you can paste VBA code directly into a Web page and have it run unchanged.
  • VBScript can be easier to learn and easier to use than JScript. A simple example will illustrate why: JScript is a case-sensitive language and VBScript is not. If you are used to writing VBA code, you are used to writing If statements beginning with a capital "I." In addition, if you inadvertently use a lowercase "I," the Visual Basic Editor capitalizes it for you. Because VBScript is case-insensitive, you can begin an If statement either way. JScript, on the other hand, requires an If statement begin with a lowercase "i." If you use a capital "I" in JScript, your script simply will not run. Debugging code is hard enough without having to worry about whether incorrect capitalization is causing a problem.

The only time you might not be able to use VBScript code in a Web page is for code used to detect the type of browser being used to view the page. VBScript code works in all versions of Internet Explorer 3.0 or later. However, VBScript code works in Netscape Navigator only by using a plug-in. Because JScript code runs in both browsers, you will want to write script that detects the browser type in JScript.

Note   Many programming techniques involve technologies designed to work best with Internet Explorer version 4.01 or later. In particular, some DHTML features might not be fully functional when they are viewed in another browser. However, these DHTML features are designed to degrade gracefully when you use a browser that does not fully support all features. Typically, this means that interactive features are inoperable and the content is displayed as static data on the page.

See Also

Working with Office Web Discussions Client | Enabling Discussions | Understanding the Global Object | Understanding Discussion Servers | Understanding Discussions | Understanding Subscriptions | Scripting in Office Applications