扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:陈琦 来源:yesky 2007年10月15日
关键字:
Declare Function PRINTDLG Lib "comdlg32.dll" Alias _ "PrintDlgA" (pPrintdlg As PRINTDLG) As Long Type PRINTDLG lStructSize As Long hwndOwner As Long hDevMode As Long hDevNames As Long hdc As Long flags As Long nFromPage As Integer nToPage As Integer nMinPage As Integer nMaxPage As Integer nCopies As Integer hInstance As Long lCustData As Long lpfnPrintHook As Long lpfnSetupHook As Long lpPrintTemplateName As String lpSetupTemplateName As String hPrintTemplate As Long hSetupTemplate As Long End Type |
Private Sub Command1_Click() Dim p As PRINTDLG p.lStructSize = Len(p) p.hwndOwner = Me.hWnd p.nFromPage = 1 p.nToPage = 1 p.nMinPage = 1 p.nMaxPage = 1 p.nCopies = 1 x = PRINTDLG(p) Printer.Print Text1.Text End Sub |
Do While Len(Str) > 0 str1 = Str Do While len1 > 0 And Printer.TextWidth(str1) > len1 str1 = Left(str1, Len(str1) - 1) Loop Printer.Print str1 '打印 If Len(str1) = 0 Then Exit Do '不匹配 Str = Mid(Str, Len(Str1)+1) '截断! Loop |
Open "PRN" For Output As #1 Print #1, "一行" |
Set Printer = Printers(0) ' 将预设打印机设定成第一种打印机 Set Printer = Printers(1) ' 将预设打印机设定成第二种打印机 |
Const HWND_BROADCAST = &HFFFF& |
PrinterName = "您想设定的打印机名称" Dim S As String, length As Long, hKey As Long S = String(80, Chr(0)) length = GetProfileString("devices", PrinterName, "", S, Len(S)) S = Left(S, length) Call WriteProfileString("windows", "device", PrinterName & "," & S) Call SendMessage(HWND_BROADCAST, WM_WININICHANGE, &H7FFF&, ByVal "windows") |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。