如何在Mac上使用VBA从Excel 16打开工作簿? [英] How to open a workbook from Excel 16 with VBA on MAC?
问题描述
我想在MAC 10.10上使用Excel 16的VBA从一个小宏中打开一个简单的工作簿,但是我不能.
I want to open a simple workbook from a little macro with the VBA of Excel 16 on a MAC 10.10 but I can't.
我有我的宏:
Sub Test()
Call Workbooks.Open("Classeur1.xlsm")
End Sub
在Office 11中,此功能可以正常工作,但在Office 16中却出现错误
With Office 11, this function works fine but I have an error with Office 16:
运行时错误'1004':
应用程序定义或对象定义的错误
Run-time error '1004':
Application-defined or object-defined error
你有什么想法要解决吗?
Do you have any idea to fix it please?
推荐答案
问题是Excel 2016 for Mac有一个奇怪的默认"目录,可在其中使用.我的矿井在/Users/xxxxx/Library/Containers/com.microsoft.Excel/Data
中启动.因此,您需要工作簿的完全限定路径.示例:-
The problem is Excel 2016 for Mac has a strange "default" directory that it works in. Mine starts up in /Users/xxxxx/Library/Containers/com.microsoft.Excel/Data
. You therefore need the fully qualified path to your workbook. Example:-
Sub Test()
Call Workbooks.Open("/Users/damien/Documents/Classeur1.xlsm")
End Sub
仅需注意,您无需使用Call
语句.您可以简单地做到这一点:-
Just a side note, you do not need to use the Call
statement. You could simply do this:-
Sub Test()
Workbooks.Open "/Users/damien/Documents/Classeur1.xlsm"
End Sub
这篇关于如何在Mac上使用VBA从Excel 16打开工作簿?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!