Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 293
Default One Variable Available In Three Workbooks

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default One Variable Available In Three Workbooks

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 293
Default One Variable Available In Three Workbooks

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable Link to Workbooks dfrancefort Excel Worksheet Functions 1 April 28th 05 01:15 AM
Workbooks with variable names bpmccoy Excel Programming 2 November 22nd 04 10:13 AM
Use variable across workbooks Steph[_3_] Excel Programming 2 September 29th 04 01:12 PM
Passing a variable between workbooks Rich Cooper Excel Programming 1 May 19th 04 07:27 PM
How to refer a Variable across Workbooks ? Prabhu Dev Excel Programming 1 November 27th 03 05:22 AM


All times are GMT +1. The time now is 01:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"