Solved

Cancel from Common Dialog

Posted on 1998-10-06
3
306 Views
Last Modified: 2010-04-30
When the Common Dialog is displayed (using ShowOpen), how do I know when the user selects the Cancel Option?
0
Comment
Question by:bav061998
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
mark2150 earned 30 total points
ID: 1438457
You've got to set the flag to enable the [Cancel] button and also set an error trap to handle the event.

Code to follow...
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1438458
'
' Prep for file we're looking for
'
CommonDialog1.filename = OurDir + filespec
'
' Set up filter
'
CommonDialog1.Filter = "All Files|*.*"
'
' Set flags to not show RO files, Allow long names and don't change runtime dir
'
CommonDialog1.Flags = cdlOFNNoChangeDir + _
    cdlOFNHideReadOnly +  cdlOFNLongNames
'
' Arm trap
'
On Error GoTo drain
'
' tell control to enable button
'
CommonDialog1.CancelError = True
'
' Display dialog
'
CommonDialog1.ShowOpen
'
' If you get here [Cancel] was *NOT* pressed
'
On Error GoTo 0
.


'
' Trap for [Cancel]
'
Drain:
Resume {where ever you want}

0
 

Author Comment

by:bav061998
ID: 1438459
Thank you, I got it now.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

896 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now