Newbie - Scope of variables question

C

Carol Williams

Hello everyone,

Working in Word97

In the Project Explorer:

In the Microsoft Word Objects folder, I see a document icon
"ThisDocument". I have code written in "ThisDocument" in which an
array "Text(1 to 6) as String" is dimensioned. The elements of this
array are visible in "ThisDocument".

I also have a form in the "Forms" folder called "frmDataInput" which
has its own set of code.

The code in "ThisDocument" makes "frmDataInput" visible.

After that, I want to use elements of "Text(1 to 6) as String" from
"ThisDocument" in the code within the form.

The code in the form creates errors when I refer to an element of
"Text(1 to 6) as String" which I believe are related to "visibility".

How do I make the variables in "ThisDocument" usable in
"frmDataInput"?

TIA
 
M

Martin Seelhofer

Hi Carol

You cannot access variables of class modules from the outside.
This is by design (the reason for this is that a class module contains
only a set of definitions which become runnable when an actual
object is instantiated out of it). Since ThisDocument *is* a class
module, you cannot use that one. Instead, add a standard code
module to your template/document and declare your array there
using the public or the global keyword :)

Cheers,
Martin
 
C

Carol Williams

On Wed, 14 Jan 2004 23:48:56 +0100, "Martin Seelhofer"

Hi Martin,

Thanks for your help ... and the explanation. I won't be at work
until tomorrow, so I'll give it a try then.

Regards,

Carol
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top