Example Code

Get a listing of the printers and Set the default printer Using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.


  • LabVIEW

Code and Documents



This example shows a quick way to provide the user a list of print available and set a default one.

Printing a document from LabVIEW doesn't particularly offer many options, and it's notably hard to select one printer, or to even have a listing of the available printers. Some functions in windows provide a such listing, and enable a user to select a default printer.

The attached VI searches for all the available printers, and outputs a listing of those letters. The index command allows the user to select which printer has to be the default one (index =0 => default printer = first one to be listed).


  • LabVIEW 2012 (or compatible)

Steps to Implement or Execute Code

  • Select the printer number as the default one.
  • Run the program


Additional Information or References
VI Snippet


**This document has been updated to meet the current required format for the NI Code Exchange.**

Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.


Hey Eric,

Thaks for digging through the classes to return the info.  Great for someone to use in their own code.  One piece of feedback that most code will include is to keep the current settings (ie read back the current printer and set that as the default printer again or some variation there in).  Currently, the only way to not change your current settings would be to pass an index outside of the range of printer indicies.  Just some food for thought.

B Sampson
Ceres Bio Fuels
Active Participant
Active Participant

I agree with Barney, I set the index default to -1 and got rid of the annoying out of range dialog

Active Participant
Active Participant

The In Range & Coerce needs to include the upper limit else you can't set to the last printer.


Thanks for  Eric. M, it is very useful.  I use the code with following modification. Just for your info.

The place to be fixed.jpg


Worked fine for me, just what I needed.  Thanks for sharing