使用Excel VBA打开文件

时间:2016-12-23 18:59:29

标签: excel vba

我想通过Parallels使用Excel在MacOS上运行一个宏,该宏以前一直在使用Excel在PC上运行。

当我尝试更改路径时,我收到编译错误和语法错误,如下所示:

'...
Dim SaveName As String 
SaveName = ActiveSheet.Range("B7").Text 
Workbooks.Open Filename:="X:/Boon (1)/Doggle/2016 Harvest/" & SaveName & "" 
End Sub

我也试过了:

SaveName = ActiveSheet.Range("B7").Text 
Workbooks.Open Filename:="/Users/spirulina/Google Drive/Boon (1)/Doggle/2016 Harvest/" & SaveName & "" 
End Sub

以及:

Dim SaveName As String 
SaveName = ActiveSheet.Range("B7").Text 
Workbooks.Open Filename:="\Users\spirulina\Google Drive\Boon (1)\Doggle\2016 Harvest\" & SaveName & ""

编辑:发现正确的语法是:

Workbooks.Open "X:/Boon (1)/Doggle/2016 Harvest/" & SaveName

0 个答案:

没有答案