Code:Option Explicit ' 'API function to call the printer dialog box ' Private Declare Function PrintDlg Lib "comdlg32.dll" _ Alias "PrintDlgA" (pPrintdlg As PRINTDLGS) As Long Private Type PRINTDLGS 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 PrintStruct As PRINTDLGS PrintStruct.lStructSize = Len(PrintStruct) Call PrintDlg(PrintStruct) With List1 For i = 0 To .ListCount - 1 Printer.Print List1.List(i) Next End With Printer.EndDoc 'start printer End Sub




Reply With Quote