Как?
И еще вопрос:
использую для печати объект Printer. Как распечатать документ на определенный, нужный мне принтер? Если имеется несколько доступных принтреров.
Dim objPrinter as Printer
For Each objPrinter in Printers
If objPrinter.DeviceName=sPrintersName then
...
Exit For
End If
Next objPrinter
For Each objPrinter in Printers
sDefaultPrintersName=objPrinter.DeviceName
Exit For
Next objPrinter
Declare Function GetProfileString Lib "kernel32" Alias "GetProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long
public Function GetDefaultPrinter() as string
Dim Default_Printer_Name As String
Default_Printer_Name = String(1024, Chr(0))
GetProfileString "Windows", "Device", "", Default_Printer_Name, Len(Default_Printer_Name)
Default_Printer_Name = Replace(Default_Printer_Name, Chr(0), "")
If Len(Default_Printer_Name) > 0 Then Default_Printer_Name = Left(Default_Printer_Name, InStr(1, Default_Printer_Name, ",") - 1)
GetDefaultPrinter = Default_Printer_Name
end function
Чудик писал(а):...Но как быть с определением принтера по умолчанию?
Private Sub Form_Load()
Dim objPrinter As Printer
For Each objPrinter In Printers
If objPrinter.DeviceName = frmPrint.cmbPrint(1).Text Then
ToUp:
DrawPreview
On Error GoTo errHandler
If frmPrint.chkPrint(0).value = 1 Then
If MyOrientation = 0 Then
objPrinter.Orientation = 0
Else:
objPrinter.Orientation = 1
End If
Else:
objPrinter.Orientation = PaperOrientation
End If
objPrinter.PaperSize = PaperFormat
objPrinter.PrintQuality = 300
objPrinter.ColorMode = TypePrint
objPrinter.PaintPicture Me.Picture1.Image, 0, 0
If MyOr = 1 Then objPrinter.NewPage: GoTo ToUp
If MyOr = 2 Then objPrinter.NewPage: GoTo ToUp
np = 0
objPrinter.EndDoc
Exit For
End If
Next objPrinter
Unload Me
Exit Sub
errHandler:
MsgBox "Íà ïîëó÷èëîñü ðàñïå÷àòàòü äîêóìåíò, îáëîì!", vbOKOnly, "Cancel"
Unload Me
np = 0
End Sub
Private Sub Form_Load()
Dim objPrinter As Printer
For Each objPrinter In Printers
If objPrinter.DeviceName = frmPrint.cmbPrint(1).Text Then
Set Printer = objPrinter
End If
Next objPrinter
ToUp:
DrawPreview
On Error GoTo errHandler
If frmPrint.chkPrint(0).value = 1 Then
If MyOrientation = 0 Then
Printer.Orientation = 1
Else:
Printer.Orientation = 2
End If
Else:
Printer.Orientation = PaperOrientation
End If
Printer.PaperSize = PaperFormat
Printer.PrintQuality = 300
Printer.ColorMode = TypePrint
Printer.PaintPicture Me.Picture1.Image, 0, 0
If MyOr = 1 Then Printer.NewPage: GoTo ToUp
If MyOr = 2 Then Printer.NewPage: GoTo ToUp
np = 0
Printer.EndDoc
Unload Me
Exit Sub
errHandler:
MsgBox "Íà ïîëó÷èëîñü ðàñïå÷àòàòü äîêóìåíò, îáëîì!", vbOKOnly, "Cancel"
Unload Me
np = 0
End Sub
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 193