Step-by-Step
------------
1. Start Infopath 2003.
2. On the File menu, click Design a Form.
3. In the Design a Form task pane, click New Blank Form.
4. To add the following script to your form, follow these steps:
a. On the Tools menu, point to Script, and then select On Load Event.
Microsoft Script Editor appears.
b. Replace the OnLoad function with the following code:
JScript
-------
function XDocument::OnLoad(eventObj)
{
debugger;
XDocument.UI.Alert("This is a test.");
}
VBScript
--------
Sub XDocument_OnLoad(eventObj)
Stop
XDocument.UI.Alert "This is a test."
End Sub
c. Save the script, and then close Script Editor.
5. On the File menu, point to Preview Form, and then click Default.
For more help with infopath programming please contact me at
help@lanwalker.com
Alain Vezina
Andrew Watt [MVP - InfoPath] - 15 Dec 2004 10:50 GMT
>JScript
>-------
[quoted text clipped - 10 lines]
>XDocument.UI.Alert "This is a test."
>End Sub
Ian,
If the above code was intended for beginners (as I assume it was)
having the debugger and Stop statements will, I suggest, confuse those
with little familiarity with the Script Editor debugging. Those most
likely to need such simple scripts are also those most likely not to
understand (fully?) how debugging works in the Script Editor.
XDocument.UI.Alert ("This is a test.")
will work in both VBScript and JScript (add a semicolon in JScript, if
you prefer).
Andrew Watt
MVP - InfoPath