Python Global Procedures
- Last UpdatedOct 29, 2026
- 3 minute read
The Procedures interface is used create a library of Python functions, classes, and variables that can be called by other scripting interfaces that use Python. The procedures declared here are not directly executed during runtime; they are executed when 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:
def celsius_to_fahrenheit(celsius):
fahrenheit = (celsius * (9 / 5)) + 32
return fahrenheit
def fahrenheit_to_celsius(fahrenheit):
celsius = ((fahrenheit - 32) * 5) / 9
return celsius
-
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:miles-km-conversion
def miles_to_km(miles):
km = miles * 1.6093
return km
def km_to_miles(km):
miles = km / 1.6093
return miles
# $region:cm-inches-conversion
def cm_to_inches(cm):
inches = cm / 2.54
return inches
def inches_to_cm(inches):
cm = inches * 2.54
return cm
-
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.