469,362 Members | 2,421 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

papersize or paperbin

I am trying to print to a QMS 2060 printer on 11X17 paper in the upper paper
tray. I have tried to bring up the Printer Dialog box and modify the paper
bin and paper size but although I can modify the settings my report keeps
printing on letter size. If I try the "printer.papersize = " command I
receive a run-time error '380', Invalid property value. I have tried using
"3" and "258" as the values.

Paperbin property has the same result.

Can anyone offer any advice? Thanks in advance!
Jul 17 '05 #1
4 12651
What type of report is it? Active or Crystal report?

If so then you need to open your reports in their respective programs and
change their paper sizes there, then save it again...
--
Stphane Richard
"Ada World" Webmaster
http://www.adaworld.com
"Chris Ott" <ch***@dalb.com> wrote in message
news:KX****************@news01.roc.ny...
I am trying to print to a QMS 2060 printer on 11X17 paper in the upper paper tray. I have tried to bring up the Printer Dialog box and modify the paper bin and paper size but although I can modify the settings my report keeps
printing on letter size. If I try the "printer.papersize = " command I
receive a run-time error '380', Invalid property value. I have tried using "3" and "258" as the values.

Paperbin property has the same result.

Can anyone offer any advice? Thanks in advance!

Jul 17 '05 #2
I am importing data from a flat file, performing many calculations then
printing the information directly to a network printer. I am using Visual
Basic ver 6 for this.

Thanks
Jul 17 '05 #3
On Thu, 25 Sep 2003 16:35:10 GMT, "Chris Ott" <ch***@dalb.com> wrote:
I am importing data from a flat file, performing many calculations then
printing the information directly to a network printer. I am using Visual
Basic ver 6 for this.


Ah, someone who uses Printer.Print !

It may be that the driver is not recognizing the change of paper size
- especially if it *knows* what paper is loaded in its bin

Try reading back the Papersize

Also messing with the height property

Printers are notorious for not 'understanding' a command until one has
done a dummy Printer.Print

ahem - except for setting Landscape / Portrait where that can throw an
error

I suggest that (for now) you rip the printer off the network- and test
it directly
Jul 17 '05 #4
Maybe you should try using API, ie. the DEVMODE structure and
DocumentProperties, DeviceCapabilities etc

Some years ago I had a written quite a few lines of code about printing.

For starters, here's a sub that returns all papersizes and their
corresponding long id of a printer:

Private Declare Function DeviceCapabilities Lib "winspool.drv" _
Alias "DeviceCapabilitiesA" (ByVal lpDeviceName As String, _
ByVal lpPort As String, ByVal iIndex As Long, ByVal lpOutput As String,
_
ByVal lpDevMode As Long) As Long

Private Declare Function DeviceCapabilities2 Lib "winspool.drv" _
Alias "DeviceCapabilitiesA" (ByVal lpDeviceName As String, _
ByVal lpPort As String, ByVal iIndex As Long, ptOutput As Any, _
ByVal lpDevMode As Long) As Long

Private Const DC_FIELDS = 1
Private Const DC_PAPERS = 2
Private Const DC_PAPERSIZE = 3
Private Const DC_MINEXTENT = 4
Private Const DC_MAXEXTENT = 5
Private Const DC_BINS = 6
Private Const DC_DUPLEX = 7
Private Const DC_SIZE = 8
Private Const DC_EXTRA = 9
Private Const DC_VERSION = 10
Private Const DC_DRIVER = 11
Private Const DC_BINNAMES = 12
Private Const DC_ENUMRESOLUTIONS = 13
Private Const DC_FILEDEPENDENCIES = 14
Private Const DC_TRUETYPE = 15
Private Const DC_PAPERNAMES = 16
Private Const DC_ORIENTATION = 17
Private Const DC_COPIES = 18
Private Const DCTT_BITMYD = &H1&
Private Const DCTT_DOWNLOAD = &H2&
Private Const DCTT_SUBDEV = &H4&
Private Declare Function OpenPrinter Lib "winspool.drv" Alias _
"OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, _
ByVal pDefault As Long) As Long

Private Declare Function DocumentProperties Lib "winspool.drv" _
Alias "DocumentPropertiesA" (ByVal hwnd As Long, _
ByVal hPrinter As Long, ByVal pDeviceName As String, _
pDevModeOutput As Any, pDevModeInput As Any, ByVal fMode As Long) _
As Long

Private Declare Function ClosePrinter Lib "winspool.drv" _
(ByVal hPrinter As Long) As Long

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)

Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" _
(ByVal lpDriverName As String, ByVal lpDeviceName As String, _
ByVal lpOutput As Long, ByVal lpInitData As Long) As Long



Public Function GetPrinterPaperSizes(ByRef gPaperSize() As Long, _
ByRef sPaperSize() As String, _
ByRef gPaperSizeCounter As Long) As Long
On Error GoTo Er

Dim PaperCount As Long
Dim PaperName As String
Dim sA As String
Dim tName As String
Dim iA As Long
Dim dl As Long
Dim gArray() As Integer

'initialise with failure
GetPrinterPaperSizes = 0

'is there a printer set?
If mhDCPrinter = 0 Then Exit Function

'find out how many paper names there are
PaperCount = DeviceCapabilities(mPrinterDeviceName, _
mPrinterPort, DC_PAPERNAMES, vbNullString, 0&)

'error
If PaperCount <= 0 Then Exit Function

'now dimension the string large enough to hold them all
PaperName = String$(64 * PaperCount, 0)

'get 'em
dl = DeviceCapabilities(mPrinterDeviceName, mPrinterPort, _
DC_PAPERNAMES, PaperName, 0)

If dl = -1 Then Exit Function

'ok
ReDim sPaperSize(1 To PaperCount) As String

'load the results
For iA = 1 To PaperCount
tName = Mid$(PaperName, (iA - 1) * 64 + 1)
sPaperSize(iA) = StripNulls(tName)
Next iA

'find out how many paper names there are, using the default DevMode
dl = 0
dl = DeviceCapabilities(mPrinterDeviceName, _
mPrinterPort, DC_PAPERS, vbNullString, 0&)

If dl <= 0 Or dl <> PaperCount Then Exit Function

ReDim gArray(1 To dl) As Integer

dl = DeviceCapabilities2(mPrinterDeviceName, _
mPrinterPort, DC_PAPERS, gArray(1), 0&)

If dl <= 0 Then Exit Function

ReDim gPaperSize(1 To PaperCount) As Long

For iA = 1 To PaperCount
gPaperSize(iA) = gArray(iA)
Next iA

gPaperSizeCounter = PaperCount

GetPrinterPaperSizes = 1

Er:
End Function
Also...
Private Function CreatePrinterDC(sPrinterName As String) As Long
On Error GoTo Er

Dim X As Printer
Dim dl As Long

CreatePrinterDC = 0

If mhDCPrinter <> 0 Then dl = DeleteDC(mhDCPrinter)

For Each X In Printers
If X.DeviceName = sPrinterName Then
mhDCPrinter = CreateDC(X.DriverName, X.DeviceName, 0&, 0&)
If mhDCPrinter <> 0 Then
'success
CreatePrinterDC = 1
'store these values
mPrinterDeviceName = X.DeviceName
mPrinterDriverName = X.DriverName
mPrinterPort = X.Port
'get DEVMODE
GetDEVMODE '<<< ignore this
'load data
LoadPrinterData '<<< ignore this
End If
Exit Function
End If
Next X

Er:
End Function
And...

Private Function StripNulls(OriginalStr As String) As String
On Error Resume Next
If (InStr(OriginalStr, Chr$(0)) > 0) Then
OriginalStr = Left(OriginalStr, InStr(OriginalStr, Chr$(0)) - 1)
End If
StripNulls = Trim$(OriginalStr)
End Function


This should get you started - it's been a long time since I left these
projects, anyway!

Cheers
A.

"Chris Ott" <ch***@dalb.com> wrote in message
news:2P***********@news01.roc.ny...
I am importing data from a flat file, performing many calculations then
printing the information directly to a network printer. I am using Visual
Basic ver 6 for this.

Thanks

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Pedro Feio | last post: by
reply views Thread by Raul | last post: by
1 post views Thread by JuanCarlos Gomez | last post: by
1 post views Thread by bafidi | last post: by
reply views Thread by Madern | last post: by
reply views Thread by Madern | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.