【发布时间】:2015-04-28 02:17:03
【问题描述】:
我正在尝试将 wb_ 和 ws_variables 传递给下面的函数 getinfofromclosedfile,我不断得到 wb_name 变量的 byref 参数不匹配。
Sub check_update()
Dim wb_path, wb_name, ws_name, ws_cell As String
AGuser = GetUser
If Dir("c:\users\" & AGuser & "\documents\appraiser_genie\genieold.xlsm") <> "" Then
wb_path = "c:\users\" & AGuser & "\documents\"
wb_name = "genieold.xlsm"
ws_name = "input"
ws_cell = Cells(17, 2).Address
Sheets("input").Cells(17, 2).Select = GetInfoFromClosedFile(wb_path, wb_name, ws_name, ws_cell)
End If
End Sub
Private Function GetInfoFromClosedFile(ByVal wbPath As String, _
wbName As String, wsName As String, cellRef As String) As Variant
任何帮助将不胜感激!
【问题讨论】:
-
在旁注中,这: Dim wb_path, wb_name, ws_name, ws_cell As String 不会像您认为的那样做,您需要像这样设置每个: Dim wb_path As String, wb_name作为字符串,ws_name 作为字符串,ws_cell 作为字符串
-
如果你按照@DanDonoghue 的建议去做,你的原始代码应该可以工作。 :)