建一个模块 Public Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long Public Type OPENFILENAME lStructSize As Long hwndOwner As Long hInstance As Long lpstrFilter As String lpstrCustomFilter As String nMaxCustFilter As Long nFilterIndex As Long lpstrFile As String nMaxFile As Long lpstrFileTitle As String nMaxFileTitle As Long lpstrInitialDir As String lpstrTitle As String flags As Long nFileOffset As Integer nFileExtension As Integer lpstrDefExt As String lCustData As Long lpfnHook As Long lpTemplateName As String End Type 窗体上放一个编辑框和按钮 Private Sub Command1_Click() Dim ofn As OPENFILENAME Dim strRtn As String ofn.lStructSize = Len(ofn) ofn.hwndOwner = Me.hwnd ofn.hInstance = App.hInstance ofn.lpstrFilter = "所有文件" ofn.lpstrFile = Space(254) ofn.nMaxFile = 255 ofn.lpstrFileTitle = Space(254) ofn.nMaxFileTitle = 255 ofn.lpstrInitialDir = App.Path ofn.lpstrTitle = "打开文件" ofn.flags = 6148 rtn = GetOpenFileName(ofn) If rtn >= 1 Then Text1.Text = ofn.lpstrFile Else Text1.Text = "Cancel Was Pressed" End If End Sub