Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That is pretty much what I said. (if you declare the variable Public is it
accessible outside the class - so it is a public property. if it isn't declared as public, then it is a hidden property. This is for variables declared in the declarations section). -- Regards, Tom Ogilvy "Stefi" wrote in message ... 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 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Stefi,
Declare it in a normal code module, not ThisWorkbook -- HTH Bob Phillips "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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
public variables | Excel Discussion (Misc queries) | |||
Public variables | Excel Discussion (Misc queries) | |||
Public Variables | Excel Discussion (Misc queries) | |||
Public Variables | Excel Programming | |||
Public Variables | Excel Programming |