How to Empty a Printer Queue Using VBA in Access
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.

- 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.
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.
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.
In Microsoft Access, press ALT + F11 to open the Visual Basic for Applications (VBA) editor.
Within your module or event procedure, declare the object variable by typing: Dim qd As Object
Assign the printers folder to your object using: Set qd = CreateObject("Shell.Application").NameSpace(16)
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").

Loop Through and Clear All Printer Queues
Iterate through all items within the printers namespace to clear the queues for every installed printer on the system.
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.

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.




