CommonDialog1.CancelError = False not working

I thought that CommonDialog1.CancelError = False meant that when hitting CANCEL on on a common dialog window (instead of selecting a file to be opened) would prevent the 'Run Time Error 9' that normally happens if you don't have that line in or have it set to true. I'm still getting that error by opening a commondialog and hitting cancel instead of selecting a file. Any suggestions?
JohnDoeSrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vinnyd79Commented:
What is the code trying to do after cancel is selected? Have you tried error handling?

Private Sub Command1_Click()
On Error GoTo ErrHandler
CommonDialog1.CancelError = True
CommonDialog1.ShowOpen


Exit Sub
ErrHandler:
If Err.Number = 32755 Then
    MsgBox "Cancel has been pressed"
End If
End Sub
0
Hit_MNCommented:

Run time error 9 ??
The "Cancel Error" is 20001 : in fact the typical error handler is like this:

Private Sub MyProc()

        On Error GoTo MyProc_Err

'         CODE ....

        Exit Sub

MyProc:
        If Err.Number <> 20001 Then
                ' Normal error handling here...
        End If

End Sub

So, the error 9 is not caused by the CancelError, but from something else...
Please, post your procedure for us to check.

HTH
Marco.
0
AzraSoundCommented:
If you do not have the cancel button raise an error, then right after your ShowOpen or whatever it is that you are calling, you need to check if a FileName was given (which it will not if the user clicked cancel) and take the appropriate steps in your code to avoid an error that may be raised due to an empty filename.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.