?
Solved

Cancel from Common Dialog

Posted on 1998-10-06
3
Medium Priority
?
353 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
mark2150 earned 90 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

764 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