Tag Archives: MS Office

Running Command Prompt Commands from VBA

As someone who works extensively in Microsoft Access and Excel, I often need to execute Command Prompt commands from within VBA. The standard WScript.Shell.Run method can run commands easily, but it does not capture or return their output.

To fill that gap, I created CP_GetOutput a VBA function that executes any Command Prompt command and retrieves its textual output, ready to be used in your VBA project.

Today I’m sharing both the code, a brief explanation of how it works and a few examples of who it can be used.
 
Continue reading

Mastering Loops in VBA for Office Developers

Loops form the backbone of iterative programming in VBA for Microsoft Access, allowing developers to process recordsets, validate form inputs, or manipulate arrays efficiently without writing repetitive code. VBA provides four primary loop structures, Do loops (with While/Until variations), For Next, and For Each, each designed for specific scenarios such as conditional repetition or fixed-range traversal. Selecting the right loop depends on factors like whether the iteration count is known upfront, the need for early exits, or the data structure involved, such as DAO recordsets common in Access databases.
 
Continue reading

Microsoft Releases Emergency Update for Critical Office Zero-Day CVE 2026 21509

Microsoft has just released an out of band security update to address a critical Office zero-day vulnerability, tracked as CVE 2026 21509, which is already being exploited in the wild. This development underscores the importance of staying vigilant and keeping software up to date.
 

What is CVE 2026 21509?

CVE 2026 21509 is a newly discovered vulnerability in Microsoft Office that allows attackers to execute malicious code on affected systems. Since it is being actively exploited, organizations and individual users are at immediate risk if the update is not applied.

 
Continue reading

Get a Directory Listing Using VBA

Mastering Directory Listings in VBA: Exploring Folders and Subfolders with the Dir Function and FSO

Automating directory listings in VBA is a common requirement for Excel, Access, and other Microsoft Office solutions. Whether you need to list folders, enumerate subdirectories, or recursively scan an entire directory tree, VBA provides multiple ways to interact with the Windows file system each with distinct strengths and limitations.

In this article, you’ll learn how to generate directory listings in VBA using several proven techniques, including the built-in Dir function, the FileSystemObject (FSO) model, Shell.Application, WMI, and even PowerShell integration. We’ll explore when each approach is appropriate, how to handle recursive folder traversal safely, and why certain methods, especially Dir!, fail in nested scenarios.

If you’ve ever searched for “VBA list folders and subfolders”, “VBA recursive directory listing”, or “Dir vs FileSystemObject in VBA”, this guide walks through real-world, production-ready examples you can drop directly into your projects. By the end, you’ll know exactly which technique to use for simple folder scans, deep recursive listings, or advanced system-level automation.

Methods covered in this guide include:

  • Dir function (non-recursive directory listings)
  • FileSystemObject (FSO) for recursive folder traversal
  • Shell.Application for Windows-based folder enumeration
  • WMI for system-level and remote directory queries
  • PowerShell integration from VBA

 
Continue reading

Using VBA to List Active Processes

Because of some recent work I’ve been doing trying to embed applications within an Access form (so far I’ve managed to embed Brave, Edge, PowerShell ISE, Excel, Word, …) I’ve been working with listing the active computer processes. So I thought I’d share a few procedures I’ve developed to aid me with that task.

I tried a couple different approaches to get the process listing.

Initially, I was using the cmd:

tasklist /fo csv /nh

and although it did work, it was slow and created unnecessary lag in my process (no pun intended). Eventually I turned to my tried, tested and true friend WMI!
 
Continue reading

Microsoft Office Icons Get a Modern Refresh

Microsoft Office has just rolled out a fresh new look, with its suite of apps receiving a long-awaited facelift. As of yesterday, the familiar icons for Word, Excel, PowerPoint, Outlook, and more have been refreshed, giving the productivity tools a modern, streamlined design.
 
Continue reading

Microsoft Adds Native RegExp to VBA Ahead of VBScript Deprecation

Microsoft officially announced the phased deprecation of the VBScript library in October 2023, with a detailed timeline publicly shared in May 2024. VBScript has been a foundational technology in Windows scripting and VBA projects for decades. Its deprecation impacts key VBScript components such as VBScript.RegExp for regular expressions, Scripting.FileSystemObject (FSO) for file system operations, and Scripting.Dictionary collections, which many VBA developers currently rely on.
 
Continue reading

Microsoft Answers Is Being Retired

Did you see the new heading banner that appears when you go and access the (Microsoft) Access (Database) forum on Microsoft Answers?

Microsoft 365 and Office forum Moving to Microsoft Q&A

We are excited to announce that soon, the Microsoft 365 and Office forum will be available exclusively Microsoft Q&A. This change will help us provide a more streamlined and efficient experience for all your questions and discussions.

Starting July 16, you will no longer be able to create new questions here in the Microsoft Support Community. However, you can continue to participate in ongoing discussions and create new questions on Microsoft Q&A. Thank you for your understanding and cooperation.

Continue reading

How-to Extract All The URLs From a String

I was helping out in a forum discussion in which a developer was asking for assistance in getting a listing of URLs found within a string of text and thought I’d share here the solution(s) I came up with as I’m sure he’s not the first, nor the last to need to do this type of thing.
 
Continue reading