Function 选择文件夹(Optional Title As String = "选择一个文件夹") As Variant
With Application.FileDialog(msoFileDialogFolderPicker) '4
.Title = Title
.InitialFileName = Environ("userprofile") & "\Desktop\"
If .Show = -1 Then
选择文件夹 = .SelectedItems(1)
Else
选择文件夹 = False
End If
End With
End Function
Sub 调用选择文件夹()
FolderToSelect = 选择文件夹()
If TypeName(FolderToSelect) = "Boolean" Then MsgBox "未选中": Exit Sub
MsgBox FolderToSelect
End Sub
VBA自定义函数-选择文件夹对话框
最新推荐文章于 2024-04-17 17:08:46 发布