Collection
을 만들고 그 안에 Collection
을 추가하는 하위가 있습니다.Collection.Add : 잘못된 인수 또는 잘못된 속성 할당
Sub testState()
Dim stateCopy As State
Set stateCopy = New State
stateCopy.setStateName="some name"
stateCopy.storeBudgetWorkbooks
stateCopy.storeBudgetDatas 'error on this line
End Sub
Sub storeBudgetDatas() 'inside a class named State
...
Dim year As Integer
Dim i As Integer
i = 1
For year = 2014 To 2017
Set budgetWorkbook =
ExcelApp.Application.Workbooks.Open(budgetWorkbooks(i))
MsgBox ("still here") 'this message appears
allBudgetItems.Add getBudgetData(budgetWorkbook, year) 'this line is likely to cause problems
MsgBox ("and here") 'this message doesn't appear
budgetWorkbook.Close
i = i + 1
Next
End Sub
Function getBudgetData(budgetWorkbook As Workbook, year As Integer)
...
Dim budgetItems As Collection
Set budgetItems = getBudgetItems(year)
... 'setting attributes
getBudgetData = budgetItems(year)
End Function
Function getBudgetItems(year As Integer)
...
Dim resultCollection As Collection
Set resultCollection = New Collection
Dim itemCopy As Item
Dim i As Integer
For i = LBound(budgetItemNames) To UBound(budgetItemNames)
Set itemCopy = New Item
... 'setting attributes
resultCollection.Add itemCopy
Next
Set getBudgetItems = resultCollection
End Function
내가 여기 잘못 모르겠어요 : 루프에서 첫 컬렉션을 추가 할 때 나는 Wrong number of arguments or invalid property assignment
오류가 발생합니다. getBudgetItems
은 콜렉션을 리턴합니다. getBudgetData
도 컬렉션을 반환합니다. 나는 괄호를 추가/제거하려했지만 아무 소용이 없었다.
도움을 찾을 수 있도록 귀하의 코드는 완전하지 않습니다 덜 다가오는. 하위 storeBudgetWorkbooks가 누락되어 있으며 allBudgetItems가 흐릿 해지는 문제는 무엇입니까? – Tragamor
실제 문제 행을 찾으려면 f8을 사용하여 클래스 코드를 밟았습니까 (또는 클래스 모듈에서 분리하도록 VBE를 설정 했습니까? – Rory
@Rory, 이것으로 무엇을 의미합니까? 실제 문제를 찾는 방법을 모르겠다. 함수 내부의 특정 줄이 아니라 함수 호출이있는 줄을 강조 표시한다. – Ans