获取文件名
Function msoFile(Optional filename)
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Filters.Clear
.InitialFileName = filename
.Filters.Add "TXT Files", "*.csv;*.txt"
.Filters.Add "All Files", "*.*"
.ButtonName = "OK"
.Show
FileN = .SelectedItems(1)
If FileN = "" Then: Exit Function
msoFile = FileN
End With
End Function
获取文件夹名
Function msoFolder(Optional filename)
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Filters.Clear
.InitialFileName = filename
.ButtonName = "OK"
.Show
FileN = .SelectedItems(1)
If FileN = "" Then: Exit Function
msoFolder = FileN
End With
End Function
指定文件类型保存至文件夹
Function saveFilename(Optional filename)
FileN = Application.GetSaveAsFilename(filename, filefilter:="Excel Files (*.xlsm), *.xlsm")
If FileN = "False" Then: Exit Function
saveFilename= FileN
End Function