Solved

CommonDialog Cancel Button

Posted on 1998-10-14
2
424 Views
Last Modified: 2008-03-06
OK, I'm sure its easy but I'm having trouble being able to tell if the user has pressed the Cancel button in the Printer Commondialog box.
Thanks,
Mike
0
Comment
Question by:qdsinc
2 Comments
 
LVL 4

Accepted Solution

by:
mcix earned 50 total points
ID: 1439964
Try this code:

Private Sub cmdPrint_Click()
   
    On Error GoTo err_cmdPrint_Click
    cdlgPrint.CancelError = True
    cdlgPrint.ShowPrinter
   
exit_cmdPrint_Click:
    Exit Sub
err_cmdPrint_Click:
   
        Select Case Err.Number
       
            Case cdlCancel
                MsgBox "User Cancelled"
                Resume exit_cmdPrint_Click
            Case Else
                MsgBox Err.Number & " - " & Err.Description, vbInformation, "An unexpected error"
                Resume exit_cmdPrint_Click
        End Select
Exit Sub

0
 

Author Comment

by:qdsinc
ID: 1439965
It worked, thanks alot.

Mike
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question