Re: scope of variables
From: Jonathan West (jwest_at_mvps.org)
Date: 02/24/05
- Next message: Helmut Weber: "Re: macro to find field code in multiple headers"
- Previous message: Charles Kenyon: "Re: envelopes and labels"
- In reply to: Jean-Guy Marcil: "Re: scope of variables"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 24 Feb 2005 15:22:15 -0000
"Jean-Guy Marcil" <no-spam@leaveme.alone> wrote in message
news:uDKecJoGFHA.3648@TK2MSFTNGP09.phx.gbl...
> Mark L was telling us:
> Mark L nous racontait que :
>
>> If I have VBA code in a Word document which is using a module, some
>> forms and ThisDocument (ie Document_Open and Document_Close), where
>> should I declare Public variables so that they are accessible to the
>> whole thing? In the past I would have declared such variables in the
>> Module declarations, but I think these are not being made available
>> to the ThisDocumant section of the code. Thank you for any help you
>> can give me. --
>> Mark L
>
> You cannot have public declarations in a class module (ThisDocument is a
> "special" class module).
That's not strictly true. You can have public declarations in a class
module, but they don't act as global variables, they act as public
read-write properties of the class.
>
> Create a module that you could call "PubVariables" and use it to declare
> those public variables.
That is the way to do it. Variables declared as Public and defined before
the first Sub or Function in a module will be available to all modules,
classes and UserForms within the same project.
-- Regards Jonathan West - Word MVP www.intelligentdocuments.co.uk Please reply to the newsgroup
- Next message: Helmut Weber: "Re: macro to find field code in multiple headers"
- Previous message: Charles Kenyon: "Re: envelopes and labels"
- In reply to: Jean-Guy Marcil: "Re: scope of variables"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|