属性 CancelError=true On Error GoTo Err: dlg.ShowOpen Err: If Err.Number <> 0 Then MsgBox "a"
同楼上.sub XXXXX() on error goto ErrHandle CommonDialog1.cancelerror=true '设置为T后,如果按了取消将产生cdlCancel错误 commondialog1.showopen msgbox commondialog1.filename exit suberrhandle: if err.number<>cdlCancel then msgbox err.description '只要是cdlCancel错误,就说明是按了取消. end sub
On Error GoTo Err:
dlg.ShowOpen
Err:
If Err.Number <> 0 Then MsgBox "a"
on error goto ErrHandle CommonDialog1.cancelerror=true '设置为T后,如果按了取消将产生cdlCancel错误
commondialog1.showopen msgbox commondialog1.filename exit suberrhandle:
if err.number<>cdlCancel then msgbox err.description '只要是cdlCancel错误,就说明是按了取消.
end sub