Excel 如果将此工作簿对象用作对象的中间存储,有哪些缺点?
我使用以下系统将模型对象中间存储在VBA Excel中的ThisWorkBook对象中 在此工作簿对象中Excel 如果将此工作簿对象用作对象的中间存储,有哪些缺点?,excel,vba,mvp,Excel,Vba,Mvp,我使用以下系统将模型对象中间存储在VBA Excel中的ThisWorkBook对象中 在此工作簿对象中 Private Type TView Model As UIModel 'UserInterface As UIFrm End Type Private this As TView Friend Property Get Model() As UIModel Set Model = this.Model End Property Friend Property
Private Type TView
Model As UIModel
'UserInterface As UIFrm
End Type
Private this As TView
Friend Property Get Model() As UIModel
Set Model = this.Model
End Property
Friend Property Set Model(ByVal value As UIModel)
Set this.Model = value
'Validate
End Property
从模块调用时
if ThisWorkBook.Model is nothing then
'Do Stuff
End If
此工作簿必须翻译成您的Excel语言(例如德语DieseArbeitsMappe.Model)
这是可行的,即使代码已经运行到最后,并且通常所有对象都会被销毁,模型也可以在以后被存储和调用。如果出现错误,甚至ThisWorkBook对象中的模型也会被销毁并重新初始化。但现在来谈谈这个问题:
1。这种方法有明显的缺点吗?
2。是否有更安全的方法在Excel VBA中存储对象?