Results 1 to 10 of 10

Thread: ATTN: VB Gurus

  1. #1

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    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

  2. #2

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    Ok, great, so does this meant that no one knows how to print landscape style in VB??? Or are people just ignoring me?

    ------------------
    Ryan

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    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

  4. #4

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    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

  5. #5
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    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).]

  6. #6

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    Ah, ok, I didn't know about the Printer.Orientation property. Thank you, that should help a lot.

    ------------------
    Ryan

  7. #7
    New Member
    Join Date
    Feb 2000
    Posts
    3

    Post 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.

  8. #8
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Post

    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

  9. #9

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    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

  10. #10

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    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
  •  



Click Here to Expand Forum to Full Width