View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Stefi Stefi is offline
external usenet poster
 
Posts: 2,646
Default Workbook-level public variables

Is creating a variable considered as creating a property, or otherwise: is a
variable declared in a class module a property of the class?


Tom Ogilvy ezt *rta:

You can do that, but then you have to refer to it like this

msgbox ThisWorkbook.MyVar

Since ThisWorkbook is actually a class module, you are creating a property
of the ThisWorkbook class.

--
Regards,
Tom Ogilvy

"Stefi" wrote in message
...
It seems to me a bottom-up logic (why can't I declare it public in the Sub
Workbook_Open() where I already know I will need it as public) but it

works.
Thanks!
Stefi

"Tom Ogilvy" ezt *rta:

declare it in a general module and initialize it in from any module

General Module:

Public MyVar as Long

in the ThisWorkbook Module

Private Sub Workbook_Open()
MyVar = 6
end Sub

--
Regards,
Tom Ogilvy

"Stefi" wrote in message
...
Hi all,
How can I declare a public variable (e.g. in Workbook_open event) that
will
be valid in all other regular and event modules in the workbook?
Stefi