'首先声明一个API函数,是什么意思自己去查API手册吧!
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
'然后写一个函数
'********************************************************
Private Sub OpenFile(ByVal fName As String)
ShellExecute hwnd, "open", fName, "", "", 1
End Sub
'********************************************************
'在窗体上放两个控件 Command1 , CommonDialog1
'然后写如下过程
Private Sub Command1_Click()
On Error GoTo SelErr
CommonDialog1.DialogTitle = "选择要打开的文件"
CommonDialog1.CancelError = True
CommonDialog1.ShowOpen
OpenFile CommonDialog1.FileName
SelErr:
Dim Errmsg As String
Errmsg = Error
If Errmsg = "选定“取消”。" Then
MsgBox "没有选定的文件"
Else
MsgBox Error
End If
End Sub
'完事儿了,快试试吧!!!