|
-
Feb 18th, 2000, 07:26 AM
#1
Thread Starter
Hyperactive Member
I've been looking through the MSDN files, and all I found was something about the Orientation property of the CommonDialog window. I tried setting that equal to cdlLandscape but that didn't work. Do I need to change my code too? Here is my code:
Code:
Dim Rs2 As ADODB.Recordset
Dim x As Long
Dim y As Integer
Dim CurrentPage As Integer
Dim x_width As Integer
Dim x_tab As Integer
Dim y_pos As Integer
Dim Bookmark As String
Dim CopyCounter As Integer
Dim LinesPerPage As Integer
Set Rs2 = Connection.Execute("SELECT COUNT(*) FROM Inventory")
LinesPerPage = Printer.ScaleHeight \ Printer.TextHeight(" ")
x_width = 110
x = Rs2.Fields(0).Value
CommonDialog1.min = 1
CommonDialog1.Max = x \ LinesPerPage + IIf(x Mod LinesPerPage > 0, 1, 0)
CommonDialog1.Flags = cdlPDNoSelection Or cdlPDHidePrintToFile
On Error GoTo ERROR
CommonDialog1.CancelError = True
CommonDialog1.ShowPrinter
CommonDialog1.Orientation = cdlLandscape
Bookmark = Rs.Fields("product_id").Value
For CopyCounter = 1 To CommonDialog1.Copies
Rs.MoveFirst
y_pos = Printer.CurrentY
x_tab = 0
CurrentPage = 1
Printer.Print "UPC"
Printer.CurrentY = y_pos
Printer.CurrentX = x_tab + x_width * (txtupc.MaxLength + 1)
x_tab = Printer.CurrentX
Printer.Print "Description"
Printer.CurrentY = y_pos
Printer.CurrentX = x_tab + x_width * (txtdescription.MaxLength + 1)
x_tab = Printer.CurrentX
Printer.Print "Cost"
Printer.CurrentY = y_pos
Printer.CurrentX = x_tab + x_width * (txtcost.MaxLength + 1)
x_tab = Printer.CurrentX
Printer.Print "QOH"
Printer.CurrentY = y_pos
Printer.CurrentX = x_tab + x_width * (txtqoh.MaxLength + 1)
x_tab = Printer.CurrentX
Printer.Print "Vendor"
Printer.CurrentY = y_pos
Printer.CurrentX = x_tab + x_width * (txtvendor.MaxLength + 1)
x_tab = Printer.CurrentX
Printer.Print "Vendor Code"
Rs.MoveFirst
If CurrentPage < CommonDialog1.FromPage Then
Rs.Move (LinesPerPage * (CommonDialog1.FromPage - 1) - 1)
CurrentPage = CommonDialog1.FromPage
End If
x_tab = 0
Do While Not Rs.EOF
y_pos = Printer.CurrentY
x_tab = 0
Printer.CurrentX = x_tab
Printer.Print Rs.Fields("upc").Value
Printer.CurrentY = y_pos
Printer.CurrentX = x_tab + x_width * (txtupc.MaxLength + 1)
x_tab = Printer.CurrentX
Printer.Print Rs.Fields("description").Value
Printer.CurrentY = y_pos
Printer.CurrentX = x_tab + x_width * (txtdescription.MaxLength + 1)
x_tab = Printer.CurrentX
Printer.CurrentX = x_tab + x_width * (txtcost.MaxLength) - Printer.TextWidth(Rs.Fields("cost").Value)
Printer.Print Rs.Fields("cost").Value
Printer.CurrentY = y_pos
Printer.CurrentX = x_tab + x_width * (txtcost.MaxLength + 1)
x_tab = Printer.CurrentX
Printer.Print Rs.Fields("qoh").Value
Printer.CurrentY = y_pos
Printer.CurrentX = x_tab + x_width * (txtqoh.MaxLength + 1)
x_tab = Printer.CurrentX
Printer.Print Rs.Fields("vendor").Value
Printer.CurrentY = y_pos
Printer.CurrentX = x_tab + x_width * (txtvendor.MaxLength + 1)
x_tab = Printer.CurrentX
Printer.Print Rs.Fields("vendor_code").Value
Printer.CurrentX = x_tab + x_width * (txtvendor_code.MaxLength + 1)
Rs.MoveNext
If Printer.CurrentY >= (Printer.ScaleHeight - Printer.TextHeight(" ")) And Not Rs.EOF Then
If CurrentPage = CommonDialog1.ToPage And (CommonDialog1.Flags And cdlPDPageNums) Then
Exit Do
End If
Printer.NewPage
CurrentPage = CurrentPage + 1
End If
Loop
Printer.EndDoc
Next CopyCounter
Rs.MoveFirst
Rs.Find ("product_id = '" & Bookmark & "'")
Exit Sub
ERROR:
Exit Sub
End Sub
------------------
Ryan
------------------
Ryan
-
Feb 21st, 2000, 06:05 AM
#2
Thread Starter
Hyperactive Member
Ok, great, so does this meant that no one knows how to print landscape style in VB??? Or are people just ignoring me?
------------------
Ryan
-
Feb 21st, 2000, 06:20 AM
#3
I think this topic was raised quite a few times. The question was how to print the document in a Landscape. So, I guess, nobody is answering, because they already know that this CommonDialog1.Orientation = cdlLandscape exist.
------------------
Serge
Senior Programmer Analyst
[email protected]
[email protected]
ICQ#: 51055819
-
Feb 21st, 2000, 06:52 AM
#4
Thread Starter
Hyperactive Member
But as I said in my original post, I already tried setting CommonDialog1.Orientation = cdlLandscape and it did not work. So what am I not doing to make this work properly?
------------------
Ryan
-
Feb 21st, 2000, 09:00 AM
#5
The CommonDialogs Orientation Property is set when the User Selects their Printer Options, it's then upto you to Set the Printer Objects Orientation from the Value of the CommonDialog, ie.
Code:
CommonDialog1.CancelError = True
CommonDialog1.ShowPrinter
Printer.Orientation = CommonDialog1.Orientation
'Etc..
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Certified AllExperts Expert
[This message has been edited by Aaron Young (edited 02-21-2000).]
-
Feb 21st, 2000, 09:10 AM
#6
Thread Starter
Hyperactive Member
Ah, ok, I didn't know about the Printer.Orientation property. Thank you, that should help a lot.
------------------
Ryan
-
Mar 5th, 2000, 06:14 PM
#7
New Member
Landscape Problem
The printer.orientation and the api devmode structure
for control the printer orientation , don't function with
all printers , for example with epson 440 .
I think that problem of these printers is that they don't use the standard option panel , but the personal epson panel.
-
Mar 6th, 2000, 01:04 AM
#8
I noticed that you use a loop, to print a number of copies.
An easier, and faster, way is to set the Copies property of the printer object:
Printer.Copies = CommonDialog1.Copies
-
Mar 6th, 2000, 05:39 AM
#9
Thread Starter
Hyperactive Member
So, Frans C, you're saying that if I just do this:
Printer.Copies = CommonDialog1.Copies
then I can take out the CopyCounter Loop? Just delete the For...Next and it'll still work?
-Ryan
I smell varmint poontang, and the only good varmint poontang is dead varmint poontang...
-Bill Murray, Caddyshack
-
Mar 6th, 2000, 06:20 AM
#10
Thread Starter
Hyperactive Member
Ok, yeah, that works, but how can I make it collate? Is there an easy way to do that? Because right now it prints the appropriate number of copies of each page before it moves on to the next.
-Ryan
I smell varmint poontang, and the only good varmint poontang is dead varmint poontang...
-Bill Murray, Caddyshack
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|