Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

Dim Printer As New Printer Printer.PrintAction = Printing.PrintAction.PrintToPreview Printer.PaperSize = vbPRPSLegal Printer.Print("Using legal size paper") Printer.

EndDoc() sub TestPrint(0 Printer.ScaleMode = 1 Printer.PaperSize = 256 ' or Printer.PaperSize = vbPRPSUser Printer.Height = 8.5 * 1440 Printer.Width = 7 * 1440 Printer.Orientation = 1 Printer.Print Printer.EndDoc End sub

pilih printer Dim prt As Printer For Each prt In Printers If prt.DeviceName = "MyPrinterName" Then Set Printer = prt Exit For End If Next

Sub Cetak() On Error GoTo err_han ' hidupkan property CancelError untuk menangkap error saat cancel ' saat dipilih Cancel akan timbul error nomor 32755 ' error tersebutlah yang akan kita tangkap untuk pembatalan Me.CommonDialog1.CancelError = True ' munculkan printer dialog Me.CommonDialog1.ShowPrinter ' contoh data yang akan dicetak Printer.Print "Test" Printer.EndDoc Exit Sub err_han: If Err.Number = 32755 Then MsgBox "Cetak dibatalkan", vbInformation End If End Sub

You might also like