Sorry ,刚刚贴错了。
CancelError = true   

解决方案 »

  1.   

    '         Purpose:   
      '           Author:吴文智   
      '               Date:2001-11-13   
      'Description:要试用本例请在窗体中填加一个CommonDialog和一个按钮   
      '                         然后在代码窗体中粘贴如下代码   
      '                         Good   luck!   
        
      Option   Explicit   
        
      Private   Sub   Command1_Click()   
              On   Error   GoTo   ErrHandle   
                
              With   CommonDialog1   
                      '用户取消时触发错误   
                      .CancelError   =   True   
                      .Filter   =   "文本文件|*.txt"   
                      .ShowOpen   
                      MsgBox   .FileName   
              End   With   
                
              Exit   Sub   
                
      '错误处理   
      ErrHandle:   
              Select   Case   Err.Number   
              Case   32755   
                      MsgBox   "用户取消",   vbInformation   
              Case   Else   
                      MsgBox   Err.Description,   vbCritical,   Err.Number   
              End   Select   
      End   Sub