'在
文件对话框对中返回选择一个文件夹的路径.Public Function ChooseFolder() As StringDim dlgOpen As FileDialogSet dlgOpen = Application.FileDialog(msoFileDialogFolderPicker)With dlgOpenIf .Show = -1 ThenChooseFolder = .SelectedItems(1)End IfEnd WithSet dlgOpen = NothingEnd Function'--------------------------------------------------------'在文件对话框
对中,选择一个文件。
代码如下:
Sub GetFile()
Dim FolderPicker As Object
Dim FilePath As String
Set FolderPicker = Application.FileDialog(msoFileDialogFilePicker)
With FolderPicker
.Filters.Clear
.Filters.Add "文本文件", "*.txt"
If .Show = -1 Then
FilePath = .SelectedItems(1)
Else
Exit Sub
End If
End With
End Sub
评论列表(0条)