Results 1 to 3 of 3

Thread: Which Button? Common Dialog

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Posts
    72
    I currently display the Common Dialog box for Printer. How can you catch the button that was pressed. Ie: did the user select the "OK" or the "Cancel"

    thanks in advance
    VB 6 Professional Edition

  2. #2
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722
    Use :
    CommonDialog.CancelError = True

    If the user clicks on Cancel, the Dialog will return an error. Else it returns 0

    Code:
    On Error Resume Next
    CommonDialog1.CancelError = True
    CommonDialog1.Action = 6 'I think
    If Err = 0 then 'User clicked OK
        'Do your printing here
    ElseIf Err = 32755 'User clicked Cancel
        'Do NOT print
    End If

    r0ach™
    Don't forget to rate the post

  3. #3
    Guest
    Try this code. Make a Form with a CommonDialog and put the following code into a CommandButton.

    Code:
    On Error Resume Next
    'Generate an error when Cancel is selected
    CommonDialog1.CancelError = True
    CommonDialog1.ShowPrinter
    
    If Err <> 32755 Then
        'User Pressed OK
        Print "You pressed OK"
    Else
        'User Pressed Cancel
        Print "You pressed Cancel"
    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