Thread: Use of PUBLIC
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
BillCPA BillCPA is offline
external usenet poster
 
Posts: 101
Default Use of PUBLIC

This looks like a good solution. I was considering creating a separate
'control' file for one spreadsheet to write to and then the other one read
from. But I assume this will be much faster.

If I could pick your brain just a little bit further - I've heard of the
'registry', but never done anything with it. (Perhaps you might post one of
your SaveSetting lines fo code - I've always done better with real-life
examples.)

In the SaveSetting Help, it mentions the 'section' parameter where the
setting is to be saved - is there someplace I can find a list of these
sections, and does it matter which section the data is saved in? And are
there any restrictions on what can be used for the 'key' parameter?

I've been looking for a solution to this for a long time - if this works as
it looks like it will, i will be extremely grateful.

--
Bill @ UAMS


"Chris Gorham" wrote:

I think the PUBLIC statement makes variables available only within modules of
the workbook containing that statement...don't take that as gospel, but
that's what I've always assumed...

Use the SaveSetting and GetSetting statements to save a variable in the
registry for use later or (I assume this should work) another workbook thats
open at the same time.

I use it all the time for saving values of variables for when the Add-In's I
design are next loaded...

Chris

"BillCPA" wrote:

I need some help in understanding the use of the PUBLIC statement.

VBA Help for PUBLIC states that "Variables declared using the Public
statement are available to all procedures in all modules in all
applications...". I have taken that to mean that if I am running VBA in one
spreadsheet, and it opens a second spreadsheet, the PUBLIC variables in the
first code are available to the code in the second application. But that
doesn't seem to be the case. Is this an incorrect interpretation, or am I
not doing something right?

If this is not the way PUBLIC works, is there some other way for a file
(FILE B) opened by another file (FILE A) to use variables defined in the
original file (FILE A)?

If nothing else, is there a way for FILE A to write a value to a particular
memory location, and then have FILE B read from that memory location?
--
Bill @ UAMS