Printing Problems

How to Empty a Printer Queue Using VBA in Access

Steven ParkerSteven Parker Oct 23, 2026 868 views

Question details

The user needs to use VBA within Access 2019 to programmatically clear the queue for either a specific printer or all installed printers.

How to Empty a Printer Queue with VBA in Access
Product
Microsoft Access 2019
Device & OS
not provided
Scenario
A transaction receipt remains stuck in the printer queue after being declined by a customer, causing it to print simultaneously with the next valid receipt.
Observed behavior
Unwanted pending print jobs are not automatically discarded and remain in the queue, requiring a VBA solution to purge them before processing new jobs.
Before you start

Verify the exact name of your target printer as registered in your system's Devices and Printers folder, and note that executing this code will permanently delete all pending print jobs for that device.

Solution 1Recommended

Clear a Specific Printer Queue using Shell.Application

Use the Windows Shell.Application object in VBA to target a specific printer by its exact name and invoke the system's Empty command.

This method accesses the Windows Shell environment to replicate the manual action of clearing a print queue. It utilizes the NameSpace(16) identifier, which corresponds to the system's Printers folder.

1
Open the VBA Editor

In Microsoft Access, press ALT + F11 to open the Visual Basic for Applications (VBA) editor.

2
Declare the Queue Object

Within your module or event procedure, declare the object variable by typing: Dim qd As Object

3
Initialize the Printers Namespace

Assign the printers folder to your object using: Set qd = CreateObject("Shell.Application").NameSpace(16)

4
Invoke the Empty Verb

Call the specific printer and empty the queue using: qd.ParseName("Your Exact Printer Name").InvokeVerb "Empty". Replace "Your Exact Printer Name" with the actual name (e.g., "EPSON WF-2650 Series").

Clear a Specific Printer Queue using Shell.Application
Syntax Caution: Ensure you apply the InvokeVerb method directly to the parsed object. An incorrect printer name string will result in an 'Object variable or With block variable not set' error.
Free Microsoft Office alternative

Looking for a fast and lightweight Office suite?

While WPS Office does not feature a direct database application like Access, it provides powerful, free, and lightweight tools for your documents, spreadsheets, and presentations. WPS Spreadsheet includes robust VBA and macro support for extensive automation tasks.

Free, comprehensive Office suite for daily tasksSeamless compatibility with Microsoft Excel, Word, and PowerPoint formatsBuilt-in Macro and VBA support in WPS SpreadsheetFamiliar user interface requiring zero learning curve
microsoft office alternative - wps office

Frequently Asked Questions

Why do I get an object-variable error when using ParseName in VBA?

This error typically occurs if the printer name provided in the ParseName string does not exactly match the actual printer name in the Windows system. Ensure the spelling, spacing, and casing match perfectly (e.g., 'EPSON WF-2650 Series').

What does NameSpace(16) refer to in the Shell.Application object?

NameSpace(16) is a special system folder constant in the Windows Shell API. It specifically points the Shell object to the local 'Printers and Faxes' folder, allowing programmatic access to installed printers.

Will invoking 'Empty' delete paused or error-state print jobs?

Yes. Invoking the 'Empty' command via the Shell object triggers the system's standard queue purge operation, which removes all pending jobs from the queue, regardless of whether they are paused or stuck in an error state.