Sub SelectFolderDialog() '通过对话框选择文件夹 With Application.FileDialog(msoFileDialogFolderPicker) .Title = "Select Folders" If .Show Then ipath = .SelectedItems End If End With If IsEmpty(ipath) Then Exit Sub '如果按取消键,退出 Debug.Print ipath(1) '输出文件夹路径 End Sub 作者:weilo...
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BrowseInfo) As Long Private Function DialogSelectFolder(hOwner As Long, psTitle As String) As String Dim udtBrowseInfo As BrowseInfo, sPath As String With udtBrowseInfo .hOwner = hOwner .pIDLRoo...
Sub SelectFolderDialog() '通过对话框选择文件夹 With Application.FileDialog(msoFileDialogFolderPicker) .Title = "Select Folders" If .Show Then ipath = .SelectedItems End If End With If IsEmpty(ipath) Then Exit Sub '如果按取消键,退出 Debug.Print ipath(1) '输出文件夹路径 End Sub...
The line below displays thefolder dialog. If the user chooses to cancel the dialog, the value “0” will be assigned to intZero. Otherwise the value “-1” is assigned: intResult = Application.FileDialog(msoFileDialogFolderPicker).Show Result: In the example above the folder “Folder to Sta...
代码语言:vba 复制 Sub RangeSelectionDialog() Dim rng As Range ' 显示范围选择对话框 Set rng = Application.InputBox("请选择一个范围", Type:=8) ' 处理选择的范围 If Not rng Is Nothing Then MsgBox "您选择的范围是: " & rng.Address Else MsgBox "您没有选择任何范围" End If End Sub ...
DialogType属性:只读,文件对话框类型。 FilterIndex属性:可读写,获取或设置文件对话框的默认筛选条件。 Filters属性:只读,获取FileDialogFilters集合。 InitialFileName属性:可读写,设置或返回文件对话框中默认显示的文件路径和名称。 InitialView属性:可读写,...
DialogType 可以是以下几种之一: MsoFileDialogOpen:打开文件 MsoFileDialogSaveAs:保存文件 MsoFileDialogFilePicker:选择文件 MsoFileDialogFolderPicker:选择文件夹 对话框的定制化 FileDialog 对象提供了大量属性和方法,允许你深度定制对话框的外观和行为。以下是一些关键属性: Title: 设置对话框的标题。 InitialFileName: 设...
End Select End Function Function FolderDialog(strTitle As String) As String '获取选择文件夹对话框的目录 Set objShell = CreateObject("Shell.Application") Set objDialog = objShell.BrowseForFolder(0, strTitle, 0, 0) If Not objDialog Is Nothing Then If Right(objDialog.self.Path, 1) = "\\"...
在有些情形下,我们可能需要找到指定文件夹中最新保存的工作簿,然后对其进行处理。例如,每天上班前系统...
End Select If lngType <> msoFileDialogFolderPicker Then 'Reset then add filter patterns separated by tildes (~) where ' multiple extensions are separated by semi-colons (;) and the ' description is separated from them by a comma (,). ...