Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 找不到VBA Application.FileDialog_Excel_Vba - Fatal编程技术网

Excel 找不到VBA Application.FileDialog

Excel 找不到VBA Application.FileDialog,excel,vba,Excel,Vba,我在Mac电脑上运行Excel 2011,我的一个应用程序在windows版本上运行,但在Mac电脑上无法运行。在Application.FileDialog中找不到方法“FileDialog” 我使用的是参考ms office 14.0对象库、vba、ms excel 14.0对象库、ole automation和ms forms 2.0对象库 为什么我的mac上的application类不存在FilDialog方法,但它在我的windows上工作?应用程序。FileDialog在Excel

我在Mac电脑上运行Excel 2011,我的一个应用程序在windows版本上运行,但在Mac电脑上无法运行。在Application.FileDialog中找不到方法“FileDialog”

我使用的是参考ms office 14.0对象库、vba、ms excel 14.0对象库、ole automation和ms forms 2.0对象库


为什么我的mac上的application类不存在FilDialog方法,但它在我的windows上工作?

应用程序。FileDialog
在Excel 2011中不存在。相反,它会创建一个函数

解决方案如下,并允许it在Macintosh上工作:

Function myGetOpenFileName(Optional sPath As String) As String
Dim sFile As String
Dim sMacScript As String

If isMac Then
    If sPath = vbNullString Then
        sPath = "the path to documents folder"
    Else
        sPath = " alias """ & sPath & """"
    End If
    sMacScript = "set sFile to (choose file of type ({" & _
        """com.microsoft.Excel.xls"", 
        ""org.openxmlformats.spreadsheetml.sheet"",
        ""public.comma-separated-values-text"", ""public.text"", 
        ""public.csv"",
        ""org.openxmlformats.spreadsheetml.sheet.macroenabled""}) with prompt " & _
        """Select a file to import"" default location " & sPath & ") as string" _
        & vbLf & _
        "return sFile"
     Debug.Print sMacScript
    sFile = MacScript(sMacScript)

Else 'windows

    sFile = Application.GetOpenFilename("CSV files,*.csv,Excel 2007 files,*.xlsx", 1, _
        "Select file to import from", "&Import", False)

End If