|
Examples
|
|
| 'Set document title
|
| SPrinter1.DocTitle = "Smart Print Control Demo"
|
|
|
| 'Set document title font size
|
| SPrinter1.DocTitleFont.Size = 16
|
|
|
| 'Set document text (body)
|
| SPrinter1.DocText = " Smart Print Control provides great " _
|
| "flexibility in printing your documents, by allowing you to query " _
|
| "all printers attached to the system, select a printer, specify " _
|
| "print quality, paper size, orientation, paper bin, print margins, " _
|
| "line spacing, etc. Take a look at the great features of Smart Print Control."
|
|
|
| 'Set document header
|
| SPrinter1.DocHeader = "Smart Print Control Document Header"
|
|
|
| 'Set document footer
|
| SPrinter1.DocFooter = "Smart Print Control Document Footer"
|
|
|
| 'Send document to the default system printer
|
| SPrinter1.PrintDoc
|
|
|
| 'Set document title
|
| SPrinter1.DocTitle = "Retrieving Document Body From A File"
|
|
|
| 'Set document title font
|
| SPrinter1.DocTitleFont.Size = 16
|
|
|
| 'Tell the control to retrieve only the document text (body) from a file
|
| 'Other document data (title, header, footer) are supplied from code
|
| SPrinter1.AllDataFromFile = False
|
|
|
| 'Specify the file name
|
| 'The file can have any extension but must be a text file
|
| SPrinter1.FileName = "C:\MyFolder\MyFile.txt"
|
|
|
| 'Set document header
|
| SPrinter1.DocHeader = "Sample Document Header"
|
|
|
| 'Set document footer
|
| SPrinter1.DocFooter = "Sample Document Footer"
|
|
|
| 'Send document to default system printer
|
| SPrinter1.PrintDoc
|
|
|
| 'Set document title font size
|
| SPrinter1.DocTitleFont.Size = 16
|
|
|
| 'Set document body font size
|
| SPrinter1.DocTextFont.Size = 12
|
|
|
| 'Tell the control to retrieve all document data from a file
|
| 'IMPORTANT: See the file format details
|
| SPrinter1.AllDataFromFile = True
|
|
|
| 'Specify the file name
|
| 'The file can have any extension but must be a text file
|
| SPrinter1.FileName = "C:\MyFolder\MyFile.txt"
|
|
|
| 'Set the line spacing to 1.5 lines
|
| SPrinter1.LineSpacing = spLineSpacingOneHalf
|
|
|
| 'Print a separating line below header and above footer
|
| SPrinter1.LineBelowHeader = True
|
| SPrinter1.LineAboveFooter = True
|
|
|
| 'Print the system date / time in the footer
|
| SPrinter1.IncludeDateTime = True
|
|
|
| 'Print page numbers
|
| SPrinter1.PrintPageNumber = True
|
|
|
| 'Set the print quality
|
| SPrinter1.PrintQuality = spQualityHigh
|
|
|
| 'Set the paper size to 'Letter' size
|
| SPrinter1.PaperSize = spPaperLetter
|
|
|
| 'Send document to default system printer
|
| SPrinter1.PrintDoc
|
|
|
| 'Query physical printer devices attached to the system
|
| 'This will also retrieve any logical printers (such as FAX printer
|
| 'driver, PDF printer driver, etc.)
|
| 'The method returns a variant array (string) containing the names of
|
| 'the printers found
|
| PrnNames = SPrinter1.GetPrinters
|
|
|
| 'This will print the printer names to the debug window. You can use it
|
| 'to populate a combo box with the names of printers found so the user
|
| 'can choose the printer to use
|
| 'For x = 0 To UBound(PrnNames)
|
| ' Debug.Print PrnNames(x)
|
| 'Next
|
|
|
| 'Set document title font size
|
| SPrinter1.DocTitleFont.Size = 16
|
|
|
| 'Set document body font
|
| SPrinter1.DocTextFont.Size = 12
|
|
|
| 'Tell the control to retrieve all document data from a file
|
| 'IMPORTANT: See the file format details
|
| SPrinter1.AllDataFromFile = True
|
|
|
| 'Specify the file name
|
| 'The file can have any extension but must be a text file
|
| SPrinter1.FileName = "C:\MyFolder\MyFile.txt"
|
|
|
| 'Set the line spacing to 1.5 lines
|
| SPrinter1.LineSpacing = spLineSpacingOneHalf
|
|
|
| 'Print a separating line below header and above footer
|
| SPrinter1.LineBelowHeader = True
|
| SPrinter1.LineAboveFooter = True
|
|
|
| 'Print the system date / time in the footer
|
| SPrinter1.IncludeDateTime = True
|
|
|
| 'Send document to the first printer found (the printer is passed by
|
| 'its name as argument)
|
| MyPrinter = PrnNames(0)
|
| SPrinter1.PrintDoc(MyPrinter)
|
|
|
| [A]
|
| 'Print the RTF file using default settings for margines, paper size, paper bin, etc.
|
| SPrinter1.PrintRTFFile "C:\MyRTFFile.rtf"
|
|
|
| [B]
|
| 'Print the RTF file with custom margin settings (margin values are in Twips)
|
| SPrinter1.PrintRTFFile "C:\MyRTFFile.rtf", 1720, 2880, 1720, 2880
|
|
|
| [C]
|
| 'Print the RTF file using custom printer settings (paper size, paper bin, orientation, etc.)
|
| SPrinter1.PrintRTFFile "C:\MyRTFFile.rtf", , , , , spOrientationLandscape, spPaperA4
|
|
|
| [A]
|
| 'Print the RTF document using default settings for margines, paper size, paper bin, etc.
|
| 'RTF data are read from our RTF text box using the TextRTF property and is passed
|
| 'to the PrintRTFData method argument
|
| SPrinter1.PrintRTFData From1.RichTextBox1.TextRTF
|
|
|
| [B]
|
| 'Print the RTF document with custom margin settings (margin values are in Twips)
|
| SPrinter1.PrintRTFFile From1.RichTextBox1.TextRTF, 1720, 2880, 1720, 2880
|
|
|
| [C]
|
| 'Print the RTF document using custom printer settings (paper size, paper bin,
|
| 'orientation, etc.)
|
| SPrinter1.PrintRTFFile From1.RichTextBox1.TextRTF, , , , , spOrientationPortrait, spPaperLetter
|
|
|
|
|
| 'Print the HTML document (file) by just sepcifying the file name
|
| 'The document will be printed exactly as you see it in your web browser
|
| '(including text, images, etc.)
|
| 'For more details, see the PrintHTMLFile method
|
| SPrinter1.PrintHTMLFile "C:\MyHTMLFile.htm"
|
|
|
|
|