Private Sub Command1_Click()
Me.CommonDialog1.CancelError = True
Me.CommonDialog1.PrinterDefault = False
Me.CommonDialog1.Flags = PrinterConstants.cdlPDReturnDC
On Error Resume Next
Call CommonDialog1.ShowPrinter
On Error GoTo 0
If Err.Number <> 0& Then
Exit Sub
End If
Dim hDeviceContext As Long
hDeviceContext = Me.CommonDialog1.hDC
If hDeviceContext > 0& Then
Exit Sub
End If
Me.RichTextBox1.Text = "千葉! 滋賀! 佐賀!"
Me.RichTextBox1.SelStart = 0
Me.RichTextBox1.SelLength = Len(Me.RichTextBox1.Text) - 1
Call Me.RichTextBox1.SelPrint(hDeviceContext)
End Sub
|