Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default The way to make a Class and a Collection static

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrapping a Collection Class Bing Excel Programming 5 December 24th 04 11:37 AM
Need Class Collection advice R Avery Excel Programming 3 April 6th 04 10:34 AM
Collection Class problems Flemming Dahl Excel Programming 4 February 11th 04 04:41 PM
RaiseEvent from a class contained in a 2nd class collection? Andrew[_16_] Excel Programming 2 January 6th 04 04:22 PM
For/Each iteration for collection class Stelio Excel Programming 1 October 31st 03 12:46 PM


All times are GMT +1. The time now is 05:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"