Results 1 to 3 of 3

Thread: Common Dialog Printer Box

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Posts
    27

    Common Dialog Printer Box

    Hi

    I placed a common dialog box in my VB 6 program and in the "Print" command button on my form, I put "CommonDialog1.showprinter" in the Click event with the code for my report immediately following it. I am not using crystal but simply a bunch of Printer.Print, etc statements to make up my report.

    It works fine in that it shows the printer dialog box when the user clicks on the Print button but my report prints even if the user click on "Cancel" from the Printer dialog box.

    Can you show me how to make the report print only if the user clicks on OK on the printer dialog box?


    Thanks,

  2. #2
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Common Dialog Printer Box

    Try this:

    VB Code:
    1. On Error GoTo out
    2.     CommonDialog1.CancelError = True
    3.     CommonDialog1.ShowPrinter
    4.         'do ya thing!!!
    5.             Exit Sub
    6. out:
    7. 'do nothing

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

    Re: Common Dialog Printer Box

    You might want to do something like this.

    VB Code:
    1. CommonDialog1.CancelError = True
    2.     CommonDialog1.ShowPrinter
    3.         'do ya thing!!!
    4.             Exit Sub
    5. out:
    6. If Err.Number = 32755 Then
    7.     MsgBox "user pressed Cancel"
    8. End If

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