在 Mac 上使用 VBA 打开新文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7629573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 14:09:51  来源:igfitidea点击:

Opening New File using VBA on Mac

excelvbaexcel-2011

提问by Ali

I am using Excel 2011 for Mac and trying to open a new file.

我正在使用 Excel 2011 for Mac 并尝试打开一个新文件。

However, I keep getting an error that file not found even though the file is there. The code I am using is below:

但是,即使文件在那里,我也不断收到找不到文件的错误。我正在使用的代码如下:

Dim theFile As String

theFile = "/Users/Dev/Desktop/RCM/test.xls"
Workbooks.Open FileName:=theFile

Any suggestions?

有什么建议?

回答by Tim Williams

Mac uses a different path separator: switch your "/" to ":"

Mac 使用不同的路径分隔符:将“/”切换为“:”

回答by Henrik Mee L?vgret

Make the open line:

使开放线:

Workbooks.Open Filename:="/Users/John/Downloads/File.xlsx"