Log in

View Full Version : Solved: Sharing a variable between projects



Macropolis
09-30-2011, 09:54 AM
Issue: Sharing a variable between projects, or how do I indicate to a form that it has been called (loaded) from another project.

I’ve been tasked to work on a collection of report macros that are spread over a few .dot template files in Word 2003; let’s call them Project01.dot, Project02.dot and Project03.dot.

I need to be able to jump from one series of forms in Project01.dot into another series in Project03.dot and then back again, which I can do.
However, for formatting purposes (let’s say all text needs to be green in one instance and black in another), I need to set a variable to let the forms in Project03 know if they’ve intersected with the Project01 forms (in which case text is green) or if they’re just functioning within Project03 (text is black).

So, for purposes of our example, I have projects in Word 2003:

Project01.dot
Project02.dot
Project03.dot

And the forms within those projects need to flow as follows:

frmProj01_A (to) frmProj01_B (variable set to indicate format text green, and into) frmProj03_A (to) frmProj03_B (to) frmProj03_C (back into) frmProj01_C.

(Remember, the color formatting is just for example; the real formatting has to do with indentations, string trimming, etc.)

My first thought is to flag a variable to indicate when the forms are in the green mode, but I can't seem to get a variable in one project to be recognized in another, even if I declare it as public.

I'm up against a deadline, so any help or alternate solutions would be immensely appreciated.

Thanks in advance!

Frosty
09-30-2011, 11:05 AM
I have too many questions to be able to give you the answer you're looking for, and you're under a time crunch.

Why don't you simply write the variable into a file, and have the other project read the variable from that file? There are a lot of samples of that kind of code.

You can, of course, pass values between projects... but you can't explicitly reference a public variable value (to my knowledge).

The proper way to do it is to have Public functions return those values, and you could (if necessary) have another function set the public variable from outside the project.

This gets suspiciously close to class object programming... but maybe the simplest way to go forward is to simply look at writing the value to a file, and then retrieving that value.

Macropolis
10-21-2011, 08:13 AM
Belated thanks for your help!