Results 1 to 5 of 5

Thread: printer margins

  1. #1
    scoutt
    Guest
    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

  2. #2
    NeilPT
    Guest
    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.

  3. #3
    scoutt
    Guest
    thanks NeilPT, I will keep that in mind.

    Scoutt

  4. #4
    jim mcnamara
    Guest
    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

  5. #5
    scoutt
    Guest
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width