我正在构建和引用自定义对象的集合。该类名为 CProject,具有 Name 和 RefNum 两个属性。
创建和引用的代码如下所示:
Dim Projects As Collection
Sub BuildProjects()
Dim i As Integer
Set Projects = New Collection
For Each c In Worksheets("Active Projects").Range("A4:A750").Cells
If IsEmpty(c) Then
'Do some stuff
Else
If Projects.Count > 0 Then
For i = 1 To Projects.Count
If c.Value = Projects.Item(i).Name Then '<---Error Occurs Here
'Do some Duplicate Management Stuff
End If
Next i
End If
End If
Next
End Sub
当我运行此代码时,我收到错误 424:需要对象。我相信我提供了一个合格的对象标识符。有人看到我在哪里犯了错误吗?