如何解决vba for Mac中的工作簿?
我试图运行一个macros在PC上完美的作品,但是当试图在Mac上运行相同的macros,我得到错误"1004"
; 其中说该文件不能被发现。 我正在写这样的地址:
Workbooks.Open("\Macintosh HD\Usuarios\carlosstephan\Dropbox\SCEN Const.\GastosyPagosSCEN.xlsm")
有人知道如何写正确吗?
我已经用"/"
而不是"\"
来尝试,也没有效果。
popup同样的错误“with”:
With Sheets("Gastos") .Range(“A8”, .Cells(.Rows.Count, .Columns.Count)).Clear End With
错误在哪里?
除非Mac上的VBA与Windows不同,否则请更改
.Range(“A8”, .Cells(.Rows.Count, .Columns.Count)).Clear
至
.Range("A8", .Cells(.Rows.Count, .Columns.Count)).Clear
“
和”
字符不一样"
,不能用作string分隔符。
这取决于你的Mac版本。 我总是有问题让VBA在Mac上运行,Office 2016已经退步了。
见http://www.rondebruin.nl/mac/mac017.htm
in 2011 it return a path like this : Macintosh HD:Users:rdb:Desktop:YourFolder: And in 2016 a path like this : /Users/RDB/Desktop/YourFolder/ Reason is that in 2016 you must use the posix path in VBA codes
用下面的VBA代码,你会知道哪个是你的分隔符:
Separator = Application.PathSeparator
或者如果您使用中间窗口:
Debug.Print application.PathSeparator
知道分隔符后,将其replace为“工作簿”pathstring,并且不要删除空格