运行时错误 1004 Excel 2016 for Mac 宏(用于在 Excel 2011 for Mac 上工作)



所以我尝试在网上和论坛上寻找解决这个问题,但由于我似乎根本无法理解这一点,我需要一些建议。

我有一个宏,我曾经在Mac上的Excel 2011上运行,但我不再拥有了。 当我尝试在Mac上的Excel 2016上运行它时,我收到运行时错误"1004",抱歉我们找不到(文件位置(。 是否有可能被移动,重命名等错误。

代码如下

On Error Resume Next
MyPath = MacScript("return (path to documents folder) as String")
MyScript = _
"set applescript's text item delimiters to "","" " & vbNewLine & _
"set theFiles to (choose file of type " & _
" {""com.microsoft.Excel.xls""} " & _
"with prompt ""Please select a file or files"" default location alias """ & _
MyPath & """ multiple selections allowed true) as string" & vbNewLine & _
"set applescript's text item delimiters to """" " & vbNewLine & _
"return theFiles"
MyFiles = MacScript(MyScript)
On Error GoTo 0
If MyFiles <> "" Then
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
MySplit = Split(MyFiles, ",")
For N = LBound(MySplit) To UBound(MySplit)
X = ActiveWorkbook.Name
Workbooks.Open (MySplit(N))

当我看到调试时,它会在代码 Workbooks.Open (MySplit(N((
它查找的文件存在于该位置,因为它提示我时我必须选择该文件

想知道是否有人可以帮助我替换哪些代码 谢谢

遵循Mac Excel 2016 VBA - Workbook.open给出1004错误,只需修改Applescript的输出以进行文件选择(类似于Macintosh HD:Users:xxxx:Documents:yyyy.xlsx(,将:替换为/Macintosh HD替换为""即可使Workbooks.Open()工作。

相关内容

  • 没有找到相关文章

最新更新