Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95

View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?


"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP




Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Module: VB_Printer in Category Microsoft Visual Basic 6 : Printing from Total Visual SourceBook

Enhanced features for working with Printers in Visual Basic 6 (VB6)

Procedure List

Procedure Name



(Declarations) Declarations Declarations and private variables for the modVB_Printer module
PrinterListToArray Procedure Populate a passed array with a list of the current printer devices on the system
PrinterListToControl Procedure Populate a passed list box or combo box with a list of the current printer devices on the system. If you pass anything other than a list box or a combo box to this procedure, it simply exits.
PrinterSetDefault Procedure Set the application's default printer to the selected device. The strDeviceName is the name of the printer as it is known on your system. You can loop through the Printers collection to obtain a list of the valid printer DeviceNames on your system.
PrintRTFControl Procedure Print the contents of a RichTextBox. The RichTextBox control includes a method, SelPrint, to print the contents of the control. This method is of limited value because it does not let you print custom headers and footers. The PrintRTFControl procedure is designed specifically to allow the printing of custom headers and footers. This procedure requires a reference to "Microsoft Rich Textbox Control" in order to compile. This reference is automatically added when you insert an RTF control onto a form.

Example Code for Using Module: VB_Printer

' Example of the modVB_Printer module for Visual Basic 6
' To use this example:
' 1. Create a new form
' 2. Create a command button called 'cmdTest'
' 3. Create a list box called 'lstPrinters'
' 4. Create a combo box called 'cboPrinters'
' 5. Create a Rich Text control called 'rtfTest'
' 6. Paste the entire contents of this module into the new form's module

Private Sub cmdTest_Click()
  Static astrPrinters() As String
  Dim intCounter As Integer

  ' Example of PrinterListToArray
  PrinterListToArray astrPrinters

  ' print the list to the Immediate Window to verify that the array was populated
  For intCounter = 0 To UBound(astrPrinters)
    Debug.Print astrPrinters(intCounter)
  Next intCounter

  ' Example of PrinterListToControl
  ' Load the list of printers into a list box and a combo box
  PrinterListToControl lstPrinters
  PrinterListToControl cboPrinters

  ' Example of PrinterSetDefault
  ' Take the first printer in the list and make it the default printer
  ' Uncomment the following line of code to change the default printer
  ' PrinterSetDefault lstPrinters.List(0)

  Printer.Print lstPrinters.List(0)

  ' Example of PrintRTFControl
  PrintRTFControl rtfTest, 1440, "PrintRTFControl Example", "", Me.Font

End Sub

Private Sub Form_Load()
  Dim strCopy As String
  Dim intCounter As Integer

  ' Generate some RTF text
  With rtfTest
    .Text = ""
    .SelBold = True
    .SelText = "Now "
    .SelBold = False
    .SelText = "is the "
    .SelItalic = True
    .SelText = "time "
    .SelItalic = False
    .SelText = "for all good men to come to the aid of their country. "

    .SelStart = 0
    .SelLength = Len(.Text)

    strCopy = .SelRTF
    .SelStart = .SelLength

    For intCounter = 1 To 10
      .SelRTF = strCopy
    Next intCounter

  End With

  cmdTest.Caption = "Printer"

End Sub

Microsoft Access Module LibraryOverview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources