![]() |
#1
|
|||
|
|||
![]()
Hi, everybody!
I Ask, How to get the print range? (Printer can really print area) Last edited by 3dvr; 02-10-2012 at 10:37. |
#2
|
||||
|
||||
![]()
Hi.
You can't get this info from printer so you need to use properties from Page such as : Page.SizeWidth Page.SizeHeight Page.Paper ~John |
#3
|
|||
|
|||
![]()
I refer to this region,
It will change the printer: ![]() Last edited by 3dvr; 02-10-2012 at 21:59. |
#4
|
||||
|
||||
![]()
I do not believe there is a native way in VBA to do this, you can do it via some API calls. This code is 32-bit, it would need to be modified for CorelDRAW X6 64-bit.
Code:
Private Declare Function CreateIC Lib "gdi32" Alias "CreateICA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, ByVal lpInitData As Long) As Long Private Declare Function DeleteDC32 Lib "gdi32" Alias "DeleteDC" (ByVal hDC As Long) As Long Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex As Long) As Long Sub OutputMargins() GetPrintableArea "Brother MFC-5895CW Printer" End Sub Public Function GetPrintableArea(ByVal strPrinterName As String, Optional ByVal lngDevMode As Long = 0&) Dim lngPhysicalWidth As Long Dim lngPhysicalHeight As Long Dim lngLeftOffSet As Long Dim lngTopOffSet As Long Dim lngRightOffset As Long Dim lngBottomOffset As Long Dim lngLogPX As Long Dim lngLogPY As Long Dim lngLeftMargin!, lngRightMargin!, lngTopMargin!, lngBottomMargin! Dim dwReturn& Dim hPDC As Long Const PHYSICALWIDTH = 110 ' Physical Width in device units Const PHYSICALHEIGHT = 111 ' Physical Height in device units Const PHYSICALOFFSETX = 112 ' Physical Printable Area x margin Const PHYSICALOFFSETY = 113 ' Physical Printable Area y margin Const LOGPIXELSX = 88 ' Logical pixels/inch in X Const LOGPIXELSY = 90 ' Logical pixels/inch in Y Const HORZRES = 8 ' Horizontal width in pixels Const VERTRES = 10 ' Vertical width in pixels hPDC = MakePDC(strPrinterName, lngDevMode) If hPDC = 0 Then Exit Function lngLeftOffSet = GetDeviceCaps(hPDC, PHYSICALOFFSETX) lngTopOffSet = GetDeviceCaps(hPDC, PHYSICALOFFSETY) lngPhysicalWidth = GetDeviceCaps(hPDC, PHYSICALWIDTH) lngPhysicalHeight = GetDeviceCaps(hPDC, PHYSICALHEIGHT) lngLogPX = GetDeviceCaps(hPDC, LOGPIXELSX) lngLogPY = GetDeviceCaps(hPDC, LOGPIXELSY) lngRightOffset = lngPhysicalWidth - GetDeviceCaps(hPDC, HORZRES) - lngLeftOffSet lngBottomOffset = lngPhysicalHeight - GetDeviceCaps(hPDC, VERTRES) - lngTopOffSet lngTopMargin = lngTopOffSet / lngLogPY lngBottomMargin = lngBottomOffset / lngLogPY lngLeftMargin = lngLeftOffSet / lngLogPX lngRightMargin = lngRightOffset / lngLogPX Debug.Print "Min Top Margin Inches " & lngTopMargin & "; Twips: " & lngTopMargin * 1440 Debug.Print "Min Bottom Margin Inches " & lngBottomMargin & "; Twips " & lngBottomMargin * 1440 Debug.Print "Min Left Margin Inches " & lngLeftMargin & "; Twips: " & lngLeftMargin * 1440 Debug.Print "Min Right Margin Inches " & lngRightMargin & "; Twips: " & lngRightMargin * 1440 Debug.Print "Min Top Margin MM " & DblRound((lngTopMargin * 1440 / 566.9) * 10, 2) Debug.Print "Min Bottom Margin MM " & DblRound((lngBottomMargin * 1440 / 566.9) * 10, 2) Debug.Print "Min Left Margin MM " & DblRound((lngLeftMargin * 1440 / 566.9) * 10, 2) Debug.Print "Min Right Margin MM " & DblRound((lngRightMargin * 1440 / 566.9) * 10, 2) dwReturn = DeleteDC32(hPDC) End Function Public Function MakePDC(ByVal strPrinterDevice As String, Optional lngDevMode As Long) As Long Dim hDC As Long hDC = CreateIC("WINSPOOL", strPrinterDevice, vbNullString, lngDevMode) MakePDC = hDC End Function Public Function DblRound(ByVal Number As Variant, NumDigits As Long, Optional UseBankersRounding As Boolean = False) As Double Dim dblPower As Double Dim varTemp As Variant Dim intSgn As Integer If Not IsNumeric(Number) Then ' Raise an error indicating that ' you've supplied an invalid parameter. Err.Raise 5 End If dblPower = 10 ^ NumDigits ' Is this a negative number, or not? ' intSgn will contain -1, 0, or 1. intSgn = Sgn(Number) Number = Abs(Number) ' Do the major calculation. varTemp = CDec(Number) * dblPower + 0.5 ' Now round to nearest even, if necessary. If UseBankersRounding Then If Int(varTemp) = varTemp Then ' You could also use: ' varTemp = varTemp + (varTemp Mod 2 = 1) ' instead of the next If ...Then statement, ' but I hate counting on TRue == -1 in code. If varTemp Mod 2 = 1 Then varTemp = varTemp - 1 End If End If End If ' Finish the calculation. DblRound = intSgn * Int(varTemp) / dblPower End Function Code:
Min Top Margin Inches 0.1166667; Twips: 168 Min Bottom Margin Inches 0.12; Twips 172.8 Min Left Margin Inches 0.1166667; Twips: 168 Min Right Margin Inches 0.12; Twips: 172.8 Min Top Margin MM 2.96 Min Bottom Margin MM 3.05 Min Left Margin MM 2.96 Min Right Margin MM 3.05 -Shelby |
#5
|
|||
|
|||
![]()
Thank you,
I will try again.... |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
BUG: Print events don't work when printing from Print Preview | runflacruiser | CorelDRAW/Corel DESIGNER VBA | 2 | 09-08-2011 13:47 |
Simple Print Msg that comes up before print icons | fungel | General | 1 | 10-10-2010 17:23 |
Use shapes in a range | Manuel | CorelDRAW/Corel DESIGNER VBA | 1 | 09-05-2007 14:55 |
range problem | chinkyk | CorelDRAW/Corel DESIGNER VBA | 0 | 20-10-2004 11:00 |
Import - Value out of Range | ddonnahoe | CorelDRAW/Corel DESIGNER VBA | 0 | 13-04-2004 14:10 |