The way to make a Class and a Collection static
Hi Tetsuya,
Declaring the variable as a module-level variable should preserve the
object. You shouldn't have to define it as static. Perhaps if you post some
relevant code and point out where you're getting the error, others might be
able to help you out. Here's some code just in case this isn't how you're
doing it now.
Dim obj as CObject
Sub Macro1
set obj = New Cobject
obj.sometext = "Hello, World"
End Sub
Sub Macro2
MsgBox obj.sometext
End Sub
Macro1 initializes the object, Macro2 displays a property value.
--
Hope that helps.
Vergel Adriano
"Tetsuya Oguma" wrote:
Hi All,
1. How can I preserve a instanciated class even after a macro finishs
executing. I do not want to run the same routine again and again if we can
keep a class previoulsy instanciated and some data in it.
2. I was thinking of making a Collection static, but when I declare it as a
module-level variable an "Invalid outside Procedure" error gets thrown... How
should I achieve this?
Thanks,
Tetsuya Oguma, Singapore
|