Results 1 to 8 of 8

Thread: Commondialog's print dialog

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Posts
    253

    Post

    Hello!!!

    Some questions about the commondialog control's print dialog:

    1. How can I let the user to choose the start page and the end page?

    2. How can I let the user to choose if he/she wants to collate the pages in the case of multiple copies?

    3. How can I use the print dialog to select a printer and then set the crystalreports control to print to this printer?

    Thanks!!!

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    Here is part of the answer:
    Code:
    Private Sub Command1_Click()
    
       Dim BeginPage As Integer
       Dim EndPage As Integer
       Dim NumCopies As Integer
       Dim Orientation As Integer
       Dim Ndx As Integer
       ' Set Cancel to True.
       CommonDialog1.CancelError = True
       On Error GoTo ErrHandler
       ' Display the Print dialog box.
       CommonDialog1.ShowPrinter
       ' Get user-selected values from the dialog box.
       BeginPage = CommonDialog1.FromPage
       EndPage = CommonDialog1.ToPage
       NumCopies = CommonDialog1.Copies
       Orientation = CommonDialog1.Orientation
       For Ndx = 1 To NumCopies
       ' Put code here to send data to your printer.
       Next
       Exit Sub
    ErrHandler:
       ' User pressed Cancel button.
       Exit Sub
    End Sub

    ------------------
    Marty

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Posts
    253

    Post

    Hello again!!!

    Actually what I mean was, that when I call to the ShowPrinter method of the commondialog control, I get these options (StartPage, EndPage and Collate) hidden or disabled. I want to know how I can make them enabled and visible so the user can change their values.

    I also want to know how I can get the printer's name and the driver's name from the commondialog control.

    Thanks!!!

  4. #4
    New Member
    Join Date
    Dec 1999
    Posts
    1

    Post

    When you use the common dialog's showprinter method, any change to the currently selected printer automatically updates the Printer object within VB. To change the printer when printing a CR report, use the report's SelectPrinter method and assign the required Printer properties to the SelectPrinter arguments.

    Here are the 3 lines of code you need:

    cdMain.ShowPrinter
    rptBlotter.SelectPrinter Printer.DriverName, Printer.DeviceName, Printer.Port
    rptBlotter.PrintOut False


  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Posts
    253

    Post

    Thank you very much for your code!!!

    But still, Does anyone know how to enable the start page, end page and collate options?

  6. #6
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    Play around with these constants:
    cdlPDNoPageNums
    cdlPDPageNums
    cdlPDCollate

    I'm not sure how they work (I know that you have to use them with CommonDialog.Flags Property). I'm not going to try it now because it is 5:15 in the morning and I have to get some sleep now. Hope I was helpful.
    Regards QWERTY

    ------------------
    Visual Basic Programmer
    ------------------
    PolComSoft
    You will hear a lot about it.


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

    Post

    QWERTY is right. You would have to use these constants with Flags property:
    Code:
    Private Sub Command1_Click()
        With CommonDialog1
            .Flags = cdlPDNoPageNums Or cdlPDPageNums Or cdlPDCollate
            .ShowPrinter
        End With
    End Sub
    Check out VB's help or MSDN library for complete explanation of these constants.

    ------------------

    Serge

    Software Developer
    Access8484@aol.com
    ICQ#: 51055819


  8. #8
    Jorgen
    Guest

    Selecting pages

    Forrest Dragon

    I have the same problem as you. I want to enable the option button for selecting the printing from page to page. Did you ever solve the problem?

    Jorgen

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