Skip to content

Script Libraries & Constants

VBA Padlock ships with a set of ready-to-use script libraries.bas modules containing thousands of Office VBA constants and utility functions that you can add to any project. These libraries let you use named constants like xlCenter, wdAlignParagraphLeft, or msoShapeRectangle directly in your compiled scripts, without needing a type library reference.

Excel Constants

~2,900 xl* and rgb* constants for full Excel automation.

Word Constants

~2,200 wd* constants for document formatting and manipulation.

PowerPoint Constants

~1,000 pp* constants for slides, transitions, and effects.

Access Constants

~1,400 ac* constants for forms, reports, and data operations.

Office Shared

~3,350 mso* constants for shapes, fills, and shared UI elements.

Utility Libraries

Error handling and Financial functions ready for your business logic.


Learn how to import these modules into your VBA Padlock project in three easy steps.

  1. Open the Templates gallery

    In the VBA Padlock code editor, click the Templates button in the toolbar.

    Templates button in the VBA Padlock code editor toolbar

  2. Select the library you need

    Browse the categorized list on the left and click any library to preview its content and documentation.

  3. Add it to your project

    Click Add to Project. This creates a new .bas module in your project containing all the constants or functions from the selected library.


Once a library module is part of your project, any other module can access its constants by adding a References directive at the very top of the file. For instance:

References ExcelConstants

Using the References directive to import WordConstants

Using the References directive to import WordConstants

  • The References directive must appear before any Option statement or code.
  • It uses the module name (as shown in the Project Explorer), not the file name.
  • You can reference multiple modules by adding several References lines.

Explore the constants available for each Microsoft Office application.

Contains ~2,900 constants for automating Microsoft Excel. Covers the most commonly used xl* enumerations plus 150+ named RGB colors.

Excel code example

Key Categories:

CategoryExamplesCount
AlignmentxlCenter, xlLeft, xlRight20+
BordersxlContinuous, xlDash, xlDot15+
ChartsxlColumnClustered, xlLine, xlPie40+
ColorsrgbRed, rgbBlue, rgbCornflowerBlue150+
FormatsxlOpenXMLWorkbook, xlCSV, xlAddIn40+

Example:

References ExcelConstants
Function FormatReport()
Dim WS
Set WS = Application.ActiveSheet
WS.Range("A1:D1").HorizontalAlignment = xlCenter
WS.Range("A1:D10").Borders.LineStyle = xlContinuous
WS.Range("A1:D1").Interior.Color = rgbSteelBlue
FormatReport = "Done"
End Function

Helper modules for common programming tasks.

Provides 6 helper functions for structured error handling inside compiled scripts.

FunctionSignatureDescription
GetErrorInfoGetErrorInfo()Returns formatted string with Error details
FormatErrorFormatError(Num, [Desc])Returns formatted error message
HasErrorHasError()True if Err.Number <> 0
ClearErrorClearError()Clears the Err object

Example:

References ErrorHandler
Function SafeDivide(A, B)
On Error Resume Next
SafeDivide = A / B
If HasError() Then
SafeDivide = "Error: " & GetErrorInfo()
ClearError
End If
End Function