Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook-level public variables
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
|
|||
|
|||
Workbook-level public variables
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
|
|||
|
|||
Workbook-level public variables
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook-level public variables
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
|
|||
|
|||
Workbook-level public variables
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
|
|||
|
|||
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 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook-level public variables
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 |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Workbook-level public variables
Now I see, thank you!
Tom Ogilvy ezt *rta: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
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 |