在VBA中传递嵌套数组作为函数的参数导致编译错误“Expected:=”

我正在尝试构build一个数组(testSheets),其中包含一个文件名和一个文件path作为string。 然后我希望在另一个数组(shtsTmpl)中包含这个数组。 然后,我想将嵌套数组中的string传递给函数的参数(copySheets),以简单地返回msgbox中的组合文件path。

这第一位代码在msg框中成功返回“TSTSheets.xlsx”。

Sub prepSheets() Dim testSheets() As Variant ReDim testSheets(0) testSheets(0) = "TSTSheets.xlsx" Dim shtsTmpl() As Variant shtsTmpl = Array(testSheets) copySheets (shtsTmpl(0)(0)) End Sub Function copySheets(srcName As String) MsgBox (srcName) End Function 

这第二位代码返回一个编译错误,在调用copySheets函数的行上显示“Expected:=”,我不明白为什么。

 Sub testSheets() Dim testSheets() As Variant ReDim testSheets(1) testSheets(0) = "TSTSheets.xlsx" testSheets(1) = "C:\" Dim shtsTmpl() As Variant shtsTmpl = Array(testSheets) copySheets (shtsTmpl(0)(0),shtsTmpl(0)(1)) End Sub Function copySheets(srcName As String, srcPath As String) MsgBox (srcPath & srcName) End Function 

有人请向我解释为什么当函数有一个参数代码编译正确,而当函数有两个参数不正确?

请让我知道如果你需要进一步的解释。

谢谢。