Detecting clicking the Cancel Button using common dialog controls
Hi,
I want to exit a sub if a user hits the cancel button in a save/open dialog. How do I do it????
Re: Detecting clicking the Cancel Button using common dialog controls
you use CommonDialiog.ShowOpen function to display your dialog?
if yes, just after the call to ShowOpen test if
CommonDialog.FileName = ""
if yes it's because cancel have been pressed or because the user has exited the dialog without selecting a file.
Re: Detecting clicking the Cancel Button using common dialog controls
Set the cancelerror to true, and then add code for exiting the sub on your on error goto...
Re: Detecting clicking the Cancel Button using common dialog controls
CommonDialog1.CancelError = true
CommonDialog1.ShowOpen
If Err.Number <> 0 then Exit Sub
John G