The code behind Microsoft Outlook forms is always written with the Microsoft Visual Basic Scripting Engine, better known as VBScript, a small portable language, which is also used in web pages and standalone scripts.
VBScript does not support the built-in Outlook constants, such as olFolderContact. Only the constants built into VBScript, such as vbYes, are supported. For Outlook constants, you must either make a Const declaration or use the constant's literal value. Look up any constant in the object browser: Press ALt+F11 to open the VBA environment in Outlook, then press F2.
Documentation
- VBScript Language Reference
- Visual Basic for Applications Features not in VBScript -- Format() is one of the VBA functions not supported in VBScript.
Debugging VBScript
The script debugger is not available in Outlook 2010 and newer. You will need to use MsgBox commands to debug scripts.
You can use the Microsoft Script Debugger to debug Outlook 2007 and older form scripts. You need to install the HTML Source Editing / Web Scripting / Web Debugging component listed under Office Tools when you do a custom setup or add components. One way to force a script to invoke the debugger is to put a Stop statement in the code. You can also open an item using a custom form, choose Tools | Forms | Script Debugger, and then set breakpoints. Custom form script debugging is not available on Windows Vista unless Visual Studio is also installed.
Advanced VBScript techniques
Scripting Runtime Library
Use the Scripting Runtime Library to access files and folders and perform some other useful coding tasks. You can also use it in VBA code.
- FileSystemObject Basics -- Details on how to use the FileSystemObject to access files and folders in VBScript
- Delete older emails with same subject line -- Uses a Dictionary object to hold the subject and sender name. Note that the For Each loop should be changed to a countdown loop. The sample is for VBA, but it uses the Scripting.Dictionary object, from the Scripting Runtime Library.
Regular expressions
Regular expressions provide a way for searching for patterns in text, such as for email addresses. Again, you can use these techniques in VBA, not just VBScript.
For VBA use, in Tools | References, add a reference to the Microsoft VBScript Regular Expressions 5.5 library. You can then use CreateObject("VBScript.RegExp") to return a RegExp object.
Windows Script Host
Windows Script Host (WSH) lets you run Visual Basic (or Java) script directly within Windows. For basics, see Windows Script Host.
If you have WSH installed, you can launch any other program (and most files) with VBScript code like this:
Set objWSHShell = CreateObject("WScript.Shell") objWSHShell.Run("notepad.exe")
You can also access the Windows registry with WSH, something VBScript cannot do by itself. For more information and code samples, see:
Read and change a registry key using VBA
Clear SecureTempFolder automatically using VBA
Maintain Custom Settings Using the Windows Registry
RegRead method
RE: Debugging VBScript
As best as I can tell, there has not been a VBScript debugger available since Office 2007 (see link below). I have personally verified that there is no "Office Tools, HTML Source Editing / Web Scripting / Web Debugging component" available in the Office 2010 install package.
https://social.msdn.microsoft.com/Forums/en-US/b58eaf49-61d3-4d92-9a2d-daa95d872d6c/how-do-debug-vbscript-in-outlook-2010-forms?forum=outlookdev
Yeah... this was one of the pages we brought over from the now-defunct outlookcode.com web site. They all need updating.