Printer.PrintAction Property


Gets or sets a value that determines whether the print output is directed to a printer, to a print preview window, or to a file.

Namespace:   Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)


public PrintAction PrintAction { get; set; }
property PrintAction PrintAction {
    PrintAction get();
    void set(PrintAction value);
member PrintAction : PrintAction with get, set
Public Property PrintAction As PrintAction

Property Value

Type: System.Drawing.Printing.PrintAction

Returns a PrintAction enumeration.


When PrintToPrinter is selected, the print output is directed to the computer's default printer. If no printer is installed an error is raised.

When PrintToPreview is selected, the print output is displayed in a standard PrintPreviewDialog control.

When PrintToFile is selected, the print output is saved to an Encapsulated PostScript file (.eps, .ps, or .ai) in the path specified by the PrintFileName property. If no file name is specified an error is raised. Files are saved in an 8-bit Grayscale PostScript format. 24-bit RGB PostScript is not supported.


The user is not prompted for a path or file name extension. To make sure that the file has a valid path and extension, you can implement your own dialog box. To do this, use a SaveFileDialog component and assign the return value to the PrintFileName property before you call the Print method.

The following table lists the PrintAction values that are valid for the PrintAction property.

Enumeration name



The print operation is directed to a file.


The print operation is directed to a print preview dialog box.


The print operation is directed to a printer.


Functions and objects in the Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6 namespace are provided for use by the tools for upgrading from Visual Basic 6.0 to Visual Basic. In most cases, these functions and objects duplicate functionality that you can find in other namespaces in the .NET Framework. They are necessary only when the Visual Basic 6.0 code model differs significantly from the .NET Framework implementation.


The following example demonstrates how to set the PrintAction property. It requires that you have three RadioButton controls that enable the user to select a printing method.

Dim Printer As New Printer
If RadioButton1.Checked = True Then
    Printer.PrintAction = Printing.PrintAction.PrintToPrinter
ElseIf RadioButton2.Checked = True Then
    Printer.PrintAction = Printing.PrintAction.PrintToPreview
    Printer.PrintFileName = _ My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData _ 
    & "Form1.eps"
    Printer.PrintAction = Printing.PrintAction.PrintToFile
End If

See Also

Printer Class
Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6 Namespace


Return to top