-
I am using the following code and i would like to know how to control the margins for the print job.
Code:
Private Sub mnuPrint_Click()
Dim tPrintDlg As PrintDlg
Dim lFromPage As Integer
Dim lToPage As Integer
Dim lMin As Integer
Dim lMax As Integer
Dim lCopies As Integer
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 Page"
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
Me.PrintForm
Printer.EndDoc
End If
End Sub
'Code improved by vBulletin Tool (Save as...)
thanks for your time and help.
Scoutt
-
If what you mean by "Printer Margins" is the non-printing area for a printer these are set by the individual printer driver. You can get current top and left settings by using GetDeviceCaps as :
Private Function printerLeftMargin()
Dim dpiX As Long
dpiX = GetDeviceCaps(Printer.hdc,LOGPIXELSX)
printerLeftMargin =GetDeviceCaps(Printer.hdc, PHYSICALOFFSETX) / dpiX
End Function
To get TopMargin settings use the LOGPIXELSY and PHYSICALOFFSETY constants.
-
thanks NeilPT, I will keep that in mind.
Scoutt
-
Printer.ScaleLeft sets the left margin
Printer.Top - sets the top margin
Printer.Width - sets the right margin
Printer.Height - sets page length - the bottom margin
These are all in twips, unless you dink with Printer.ScaleMode
-
will those work even though I am using tPrintDlg? I think I have tried those and it didn't work, but it may have been my printer.
thanks
Scoutt