Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I know when a custom class this is the proper syntax Dim SSheet as New SSched but I want to know is how to change it globally. I use that same syntax uptop of the sheet to set it globallly, but it seems like whenever I access the page or something it resets the variable as a new variable and all my information is reset. if I *Dim SSheet as SSched* you know with out the "new" I always get an error. my question is how do I set a Global Custom Class Variable? -- Xiazer ------------------------------------------------------------------------ Xiazer's Profile: http://www.excelforum.com/member.php...o&userid=31581 View this thread: http://www.excelforum.com/showthread...hreadid=544048 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Xiazer,
I'd declare without the New & use the Workbook_Open method to initialise (Set x =New x). I'd probably declare it private to the code module & set Property Get/Set methods up to access it, but that would be doing a belt & braces job. Regards, Chris. -- Chris Marlow MCSD.NET, Microsoft Office XP Master "Xiazer" wrote: I know when a custom class this is the proper syntax Dim SSheet as New SSched but I want to know is how to change it globally. I use that same syntax uptop of the sheet to set it globallly, but it seems like whenever I access the page or something it resets the variable as a new variable and all my information is reset. if I *Dim SSheet as SSched* you know with out the "new" I always get an error. my question is how do I set a Global Custom Class Variable? -- Xiazer ------------------------------------------------------------------------ Xiazer's Profile: http://www.excelforum.com/member.php...o&userid=31581 View this thread: http://www.excelforum.com/showthread...hreadid=544048 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I've Tried the Set, and am playing with the get, but I can get the code to run but everytime I do it seems like im reseting my global var to a New. I have an Options menu(custom form), and I want to set all those to a custom class global variable on sheet1. I created a function that when called from by another sheet it will set a passed class to the global var of sheet1 *sheet1.SetVartoGlobal (Variable)* then it is supposed to set to passed variable to the global variable of sheet1. Although I alway get an error saying that the global variable doesn't equal anything. What would be the proper way to access a global variable on sheet1 from custom form code -- Xiazer ------------------------------------------------------------------------ Xiazer's Profile: http://www.excelforum.com/member.php...o&userid=31581 View this thread: http://www.excelforum.com/showthread...hreadid=544048 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
From experience if you amend your code you need to re run the 'Workbook_Open' - as I think changing the code resets the global variables. You would be able to access a public variable on sheet1 (where sheet1 is the code name - not the sheet name - i.e. what you can change in the properties window in VBA) as sheet1.variablename, provided variablename has been declared as public (or has public get/let/set accessors). As a toy problem try adding the following to the 'ThisWorkbook' code module of a new workbook; Option Explicit Public dOpenDateTime As Date Private Sub Workbook_Open() dOpenDateTime = Now End Sub Close it and open it again - type; ? ThisWorkbook.dOpenDateTime In the immediate window & you should get the date/time you opened the file. In principal I think this is the basis of what you are trying to do. To add accessors you would change; Public dOpenDateTime As Date To; Private dOpenDateTime As Date And add; Public Property Get OpenDateTime() As Date OpenDateTime = dOpenDateTime End Property Public Property Let OpenDateTime(dNewValue As Date) dOpenDateTime = dNewValue End Property I'm using Let as a Date variable type is not an object - otherwise I'd use Set & need to use Set in my Workbook_Open routine. Regards, Chris. -- Chris Marlow MCSD.NET, Microsoft Office XP Master "Xiazer" wrote: I've Tried the Set, and am playing with the get, but I can get the code to run but everytime I do it seems like im reseting my global var to a New. I have an Options menu(custom form), and I want to set all those to a custom class global variable on sheet1. I created a function that when called from by another sheet it will set a passed class to the global var of sheet1 *sheet1.SetVartoGlobal (Variable)* then it is supposed to set to passed variable to the global variable of sheet1. Although I alway get an error saying that the global variable doesn't equal anything. What would be the proper way to access a global variable on sheet1 from custom form code -- Xiazer ------------------------------------------------------------------------ Xiazer's Profile: http://www.excelforum.com/member.php...o&userid=31581 View this thread: http://www.excelforum.com/showthread...hreadid=544048 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Global Header Setting | Excel Discussion (Misc queries) | |||
Change Magnification default global setting | Setting up and Configuration of Excel | |||
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? | Excel Worksheet Functions | |||
Global Setting For All Workbooks - Filename In Footer | Excel Worksheet Functions | |||
Excel Global Variable Setting | Excel Programming |