同上添加CommonDialog控件到常用工具栏:工程/部件/Microsoft/CommonDialog Control 6.0
Private Sub DirList_Change() ' 更新文件列表框,使它与目录列表框保持同步。 filList.Path = dirList.Path End SubPrivate Sub DirList_LostFocus() dirList.Path = dirList.List(dirList.ListIndex) End SubPrivate Sub DrvList_Change() On Error GoTo DriveHandler dirList.Path = drvList.Drive Exit SubDriveHandler: drvList.Drive = dirList.Path Exit Sub End SubPrivate Sub filList_Click() Debug.Print filList.FileName End Sub
' 更新文件列表框,使它与目录列表框保持同步。
filList.Path = dirList.Path
End SubPrivate Sub DirList_LostFocus()
dirList.Path = dirList.List(dirList.ListIndex)
End SubPrivate Sub DrvList_Change()
On Error GoTo DriveHandler
dirList.Path = drvList.Drive
Exit SubDriveHandler:
drvList.Drive = dirList.Path
Exit Sub
End SubPrivate Sub filList_Click()
Debug.Print filList.FileName
End Sub