Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Greetings,
I have 2 workbooks open and need to open a 3rd. The 1st workbook needs to declare the names of all 3 workbooks as 3 variables (eg: wb1, wb2 and wb3) and do this before the last 2 are opened. Is this possible? I looked at Public and Global declarations in MS help and came away more confused then before. JLGWhiz suggested I check out Chip Pearson's web site: http://www.cpearson.com/excel/TrulyGlobalVariables.htm to answer my question about global variables. That site has a lot of very interesting things to say about global variables. However, I noticed that the global variables, in the code they were talking about, were limited to long numbers. To quote from the article - "Note that these variables may contain only Long type numeric data." This raised the question, don't my 3 variables have to be declared as workbooks and not long numbers? Can anyone clarify this question and maybe give some examples as to how this can be accomplished? Any help will be appreciated. -Minitman |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
maybe something like this, just change the names as necessary:
Dim file2 As String Dim fpath As String Dim wb2 As Workbook file2 = "book1.xls" fpath = ThisWorkbook.Path & "\" Set wb2 = Workbooks.Open(fpath & file2, ReadOnly:=True) -- Gary "Minitman" wrote in message ... Greetings, I have 2 workbooks open and need to open a 3rd. The 1st workbook needs to declare the names of all 3 workbooks as 3 variables (eg: wb1, wb2 and wb3) and do this before the last 2 are opened. Is this possible? I looked at Public and Global declarations in MS help and came away more confused then before. JLGWhiz suggested I check out Chip Pearson's web site: http://www.cpearson.com/excel/TrulyGlobalVariables.htm to answer my question about global variables. That site has a lot of very interesting things to say about global variables. However, I noticed that the global variables, in the code they were talking about, were limited to long numbers. To quote from the article - "Note that these variables may contain only Long type numeric data." This raised the question, don't my 3 variables have to be declared as workbooks and not long numbers? Can anyone clarify this question and maybe give some examples as to how this can be accomplished? Any help will be appreciated. -Minitman |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hey Gary,
Thanks for the reply. I'm afraid I may not have made the situation clear, I need to declare the workbook names as variables when the first workbook is opened and have these variables available in the other two workbooks without redeclaring them. I know I can declare them as Global but they are global only in the workbook that they are declared in and not in the other two workbooks regardless of the order the workbooks are opened in. I need these variables available in the worksheet code section, the workbook open event and in the UserForm code section. Unfortunately, this code cannot do that. Does anyone know of a way to make a truly global variable for workbook names? Any help would be appreciated. -Minitman On Fri, 5 Sep 2008 21:00:22 -0400, "Gary Keramidas" <GKeramidasATmsn.com wrote: maybe something like this, just change the names as necessary: Dim file2 As String Dim fpath As String Dim wb2 As Workbook file2 = "book1.xls" fpath = ThisWorkbook.Path & "\" Set wb2 = Workbooks.Open(fpath & file2, ReadOnly:=True) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Variable Link to Workbooks | Excel Worksheet Functions | |||
Workbooks with variable names | Excel Programming | |||
Use variable across workbooks | Excel Programming | |||
Passing a variable between workbooks | Excel Programming | |||
How to refer a Variable across Workbooks ? | Excel Programming |