简介:我已经为FileDialog
使用相同的代码(下面),其中延迟绑定用于PC和MAC很长一段时间。
我的问题:我公司的一些新MAC,其MAC版本15.1及更高版本的Office版本较新,可获得以下内容:
运行时错误438:对象不支持此属性或方法
在以下行:
Set fDialog = Application.FileDialog(3)
是否需要进行哪些修改才能使其与Office Ver 15.1 for MAC一起使用?
我的代码
Option Explicit
Function OpenXLSFileName(strPath As String, MediaName As String) As String
Dim xlsFileName As String
Dim fDialog As Object
Set fDialog = Application.FileDialog(3) ' <-- get the error here (msoFileDialogFilePicker = 3)
' FileDialog properties
With fDialog
.AllowMultiSelect = False
.Title = "Select data records file for media " & MediaName
.InitialFileName = strPath
' Add filters
.Filters.Clear
.Filters.Add "Excel files", "*.xls;*.xlsx;*.csv"
If .Show = -1 Then ' -1 means success
OpenXLSFileName = .SelectedItems(1)
Else
MsgBox "No Excel file selected !", vbExclamation, "Warning"
OpenXLSFileName = ""
End If
End With
Set fDialog = Nothing
End Function