在VB 6中将对象传递给函数

时间:2014-10-26 22:06:24

标签: vb6

Dim xyzWkB As Excel.workbook
Set xyzWkB = setGetxyzObj(reportFile.Text)
populateListCombo (xyzWkB)

该功能定义如下:

Public Function populateListCombo(activeWkB As Excel.workbook)
......
......
End Function

但在致电时populateListCombo执行时我发现错误"对象不支持此属性"

此处setGetxyzObj的定义如下:

Public Function setGetxyzObj(Optional userInput As String) As Excel.workbook
    Static xyz As New Excel.Application
    Static xyzWkB As Excel.workbook
    Set xyz = New Excel.Application
    If Not (userInput = "") Then
        Set xyzWkB = xyz.Workbooks.Open(userInput)
    End If
    Set setGetxyzObj = xyzWkB
End Function

我也尝试使用populateListCombo (setGetxyzObj()),但仍然遇到同样的错误。

0 个答案:

没有答案