我已经在VBA上设置了一个自定义集合,以便存储工作表中的多个对象并在项目上循环以创建ppt演示文稿。
不幸的是,我在创建自定义集合时遇到了麻烦:我将其设置如下,并得到了一个对象变量或带有块变量错误
Sub Funds()
Dim Funds As Collection
Dim V As Fund
Set V = New Fund
V.FundID = "V1"
V.Title = "Profile_FactSheet_Title_En"
V.Fund_MER = "V1_Mer_En"
V.Fund_Yield = "V1_Yield_End"
V.Asset_Alloc = "V1_assetAlloc_En_SourceData"
V.Asset_Alloc2 = "AAV1EN"
V.Asset_Alloc3 = "FIV1EN"
V.Asset_Alloc4 = "FIMAV1EN"
V.Title_2 = "Profile_FactSheet_Title_En"
V.Trailing = "RetV1TrailingEN"
V.Calendar = "RetV1CalendarEN"
Funds.Add V, V.FundID
结束子
当我查看此内容时,我认为所有设置都正确,但仍然出现该错误。
此外,我有一个用于集合中对象的类模块,例如:
Option Explicit
Public FundID As String
Public Title As String
Public Fund_MER As String
Public Fund_Yield As String
Public Asset_Alloc As String
Public Asset_Alloc2 As String
Public Asset_Alloc3 As String
Public Asset_Alloc4 As String
Public Title_2 As String
Public Trailing As String
Public Calendar As String
任何对此的帮助将不胜感激!!
答案 0 :(得分:0)
不要给您的收藏和副刊同名(基金)。您要么需要做:
Dim Funds As Collection
Set Funds = New Collection
OR
Dim Funds As New Collection