|
'Purpose:
'' Author: Wu Wenzhi
'Date: 2001-11-13
'Description: To try this example, add a CommonDialog and a button to the form
'Then paste the following code in the code form
'Good luck!
Option Explicit
Private Sub Command1_Click ()
On Error GoTo ErrHandle
With CommonDialog1
'Error triggered when user cancels
.CancelError = True
.Filter = "Text file | * .txt"
.ShowOpen
MsgBox .FileName
End With
Exit Sub
'Error handling
ErrHandle:
Select Case Err.Number
Case 32755
MsgBox "User cancelled", vbInformation
Case Else
MsgBox Err.Description, vbCritical, Err.Number
End Select
End Sub |
|