VBScript global Procedures
- Last UpdatedOct 29, 2026
- 4 minute read
This Procedures interface is used create a library of VBScript functions and subroutines that can be called by other scripting interfaces. The procedures declared here are never directly executed during runtime; they must be explicitly called by another script.
Note: You are not prevented from declaring two or more functions with the same name. (This includes functions copied from external files.) However, if you do, then your project may behave unexpectedly during runtime. Naming your function correctly, including unique names, is the recommended practice.
You can create as many Procedures worksheets as you want, and each worksheet can contain as many functions as you want.
Create, open, and use the Procedures worksheets:
-
In the Global tab of the Project Explorer, open the Procedures folder. There will be a VBScript folder and a Python folder. Do one of the following to open a scripting worksheet for editing:
-
To edit the default Procedures worksheet (Main Procedures) or another existing Procedures worksheet, open the appropriate folder (VBScript or Python) and then double-click the worksheet or right-click it and choose Open on the context menu.
-
To create a new Procedures worksheet, do one of the following:
-
Right-click the appropriate folder (VBScript or Python) and then select Insert on the shortcut menu.
-
On the ribbon Insert tab Global group, select Procedures File, then choose the type of sheet on the menu: VBScript or Python.


Note: The optional Description field takes a string value that will appear in the Project Explorer after the worksheet is saved.
-
-
-
Declare your functions in the interface. For example:
Option Explicit
'Keep the Option Explicit statement in the first line of this interface.
'Procedures with global scope can be implemented here
'Global variables are NOT supported in this interface
Sub MyMessage(message)
MsgBox message, 0
End Sub
Function MyAdd(number1, number2)
MyAdd = number1 + number2
Call MyMessage("The sum is" & MyAdd & ".")
End Function
Note: You can declare local variables within each procedure, but you cannot declare global variables in this interface. Use tags instead of variables.
-
Save your changes.
-
If saving the Main Procedures worksheet, the changes are saved and the functions are listed under the Main Procedures worksheet in the Project Explorer.
-
If saving a new Procedures worksheet, you will be prompted for a File Name.

The functions will be listed under the new Procedures worksheet. The displayed name of the new Procedures worksheet uses the File Name of the worksheet, for example My Procedures, followed by a colon and then the string entered in the Description field, if any; for example Library 01.

-
Organizing procedures into subfolders
If you have many procedures in a single Procedures worksheet, then you may choose to organize them into subfolders.
-
In a Procedures folder or subfolder, open the worksheet that you want to organize.
-
In the worksheet, insert the following line before the procedures that you want to group together:
'$region:foldername
…where foldername is the name of the subfolder. For example:
'$region:My Subroutines
Sub MyMessage(message)
MsgBox message, 0
End Sub
'$region:My Functions
Function MyAdd(number1, number2)
MyAdd = number1 + number2
Call MyMessage("The sum is" & MyAdd & ".")
End Function
-
Save your changes. The procedures are organized into subfolders under the Procedures worksheet in the Project Explorer as shown below:

Password protect a worksheet
You can put a password on any of your scripting worksheets to prevent them from being edited or analyzed by other users. See Password-protecting files for more information.