Re: One Word Template Macro, Two Documents, Problems with Variables
- From: Cindy M. <C.Meister-C@xxxxxxxxxx>
- Date: Tue, 27 Feb 2007 18:34:54 +0100
Hi Paul,
I have created a Word 2003 template (a business form) containing macros. ItThe best thing would be to create a CLASS and have each document instantiate
is entirely possible for a User to launch more than one instance of the
template at the same time thus creating Doument1, Document2, etc.
Whereas I want to share (the values of) specific variables between the
macros and functions of a Module, I do not want these values shared between
instances of the macros related to different documents.
its own instance of the class. This will let you store document-specific
values.
The following example illustrates the main problem:
Option Explicit '
Static Sub upTst() ' Assigned to Alt+/
Dim Count As Integer ' Value to be retained between uses
Count = Count + 1 '
StatusBar = Count ' Show us what it is
End Sub '
Pressing Alt+/ on either Document1 or Document2 (created from the Word
template holding the above macro) will display the same incremented value -
not their own version of it.
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)
.
- Prev by Date: Re: PowerPoint Question
- Next by Date: Re: Office 2007 VBA language changes
- Previous by thread: Re: Office Home and Student 2007 edition and Visual Basic Studio 2005
- Next by thread: Re: Office 2007 VBA language changes
- Index(es):
Relevant Pages
|