October 19, 2018
Hot Topics:

Anything to declare?

  • November 20, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

The print dialog is a useful function. The following code will give you access to this functionality:

Private 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 Declare Function PrintDlg_
  Lib "comdlg32.dll"_
  Alias "PrintDlgA" _
(pPrintdlg As PrintDlg) As Long 
Private Sub Command1_Click() 
Dim tPrintDlg As PrintDlg 
tPrintDlg.lStructSize = Len(tPrintDlg) 
tPrintDlg.hwndOwner = Me.hWnd 
tPrintDlg.hdc = hdc 
tPrintDlg.flags = 0 
tPrintDlg.nFromPage = 0 
tPrintDlg.nToPage = 0 
tPrintDlg.nMinPage = 0 
tPrintDlg.nMaxPage = 0 
tPrintDlg.nCopies = 1 
tPrintDlg.hInstance = App.hInstance 
lpPrintTemplateName = "Print_
Dim a 
a = PrintDlg(tPrintDlg) 
If a Then 
lFromPage = tPrintDlg.nFromPage 
lToPage = tPrintDlg.nToPage 
lMin = tPrintDlg.nMinPage 
lMax = tPrintDlg.nMaxPage 
lCopies = tPrintDlg.nCopies 
'Printing stuff here 
End If 
End Sub

Page 3 of 4

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.


Thanks for your registration, follow us on our social networks to keep up-to-date