In May 2024, Microsoft announced the phased deprecation of VBScript in Windows, as detailed in the official Windows IT Pro Blog. This change impacts VBA developers who rely on VBScript, particularly for reference libraries such as regular expressions. This post outlines the upcoming changes and provides guidance to help you future proof your VBA projects.
How VBA projects use VBScript
Visual Basic for Applications (VBA) automates tasks and extends functionality in Office applications, including Excel, Word, PowerPoint, and Access. VBScript is commonly used in VBA projects in two ways:
- Executing external .vbs scripts from VBA.
- Referencing VBScript type libraries, such as VBScript.RegExp for regular expressions.
VBScript deprecation timeline
VBScript will be deprecated in three phases.
- Phase 1 (now through 2026 or 2027): VBScript remains enabled by default as a Feature on Demand (FOD). All existing VBA projects will continue to run as they do today.
- Phase 2 (approximately 2026 or 2027): VBScript FODs will be disabled by default.
- Phase 3 (TBD): VBScript will be completely removed from future Windows releases.
- Calling .vbs scripts from VBA will no longer be supported
- References to VBScript RegExp library will break unless the Office client is updated to a supported build.
For more details, see VBScript deprecation: Timelines and next steps. Starting with Office Version 2508 (Build 19127.20154) on Windows, RegExp classes are included in the VBA for Office by default. This enables the use of RegExp functions in VBA scripts without referencing external libraries. These features require Microsoft 365 version 2508 or later.
Use RegExp classes included in VBE
The default RegExp classes in VBA in Office version 2508 or later contain four types of classes to define the object type: RegExp, Match, MatchCollection, and SubMatches. There are slight differences between objects created as early binding and as late binding. For more information on early and late binding, see Early and Late Binding on Microsoft Learn.
To create a variable for RegExp object type as early binding in VBA script, no external reference to external library is needed.
Early binding example
Sub RegExpEarlyBinding()
   ' Create a variable to hold new object.
   Dim regEx As RegExp
   ' Assign RegExp object to the variable
   Set regEx = New RegExp
   ….
Early binding with VBE runtime library works on Office versions 2508 or later, regardless of Windows client. It can’t run on older Office versions.
Early binding compatibility table
Office Version | Old Windows
(VBScripts enabled) |
New Windows
(VBScripts disabled/removed) |
Microsoft 365 (before 2508) | Cannot run | Cannot run |
Microsoft 365 (2508 or later) | Can run | Can run |
Late binding example
You can also create a variable for RegExp object type as late binding in VBA script just as you did before.
Sub RegExpLateBinding()
Dim regEx As Object
' Assign RegExp object to the variable
Set regEx = CreateObject("VBScript.RegExp")
…
Late binding works on Office versions 2508 or later, regardless of Windows client version and on earlier Windows versions with VBScript enabled, regardless of the Office client version. It cannot run older Office versions before 2508 on the new Windows with VBScripts disabled or removed.
Late binding compatibility table
Office Version | Old Windows
(VBScripts enabled) |
New Windows
(VBScripts disabled/removed) |
Microsoft 365 (before 2508) | Can run | Cannot run |
Microsoft 365 (2508 or later) | Can run | Can run |
Compatibility of VBA referenced VBScript RegExp libraries
VBA scripts using VBScript RegExp libraries created from Office versions before 2508 will still work with Office 2508 or later, as well as on Windows where VBScripts is enabled. If VBScripts is disabled or removed, these scripts won’t run in Office versions earlier than 2508.
Recommendations
- Upgrade to the latest Office version. Ensure you’re on a Microsoft 365 Version 2508, build 19127.20154 or later for compatibility with the new RegExp implementation.
- Use RegExp included in the VBE in new macros. Office provides RegExp functionality in VBE in version 2508 and later, already referenced by default in the VBA environment—no need to manually add vbscript.dll.
- Test your projects. Test your VBA projects in environments where VBScript is disabled to i identify any hidden dependencies.
We’d love to hear from you!
We value your feedback and suggestions. You can submit feedback directly within Office applications such as Excel by clicking the Help Improve Office smile button in the top right corner, or by navigating to Help > Feedback in the menu. You can also respond in the comments section of this blog post.
Happy coding!
0 comments
Be the first to start the discussion.