Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Mon, 11 Aug 2008 12:32:01 -0700,    group: microsoft.public.word.vba.general        back       


How do I init a variable defined in the Options Explicit area?   
I defined a variable in the Options Explicit area but I need it set to an 
initial value to it.  This is in WORD 2007 VBA code.
date: Mon, 11 Aug 2008 12:32:01 -0700   author:   BearMarquez

Re: How do I init a variable defined in the Options Explicit area?   
BearMarquez wrote:
> I defined a variable in the Options Explicit area but I need it set
> to an initial value to it.  This is in WORD 2007 VBA code.

Put it on the left side of an assignment statement in some procedure, 
preferably the procedure that runs first.

Also, be sure you really need the variable to be in that area, which makes 
it a "global" variable. The trouble with global variables in general is 
that, while they're available in all procedures, they can also be changed in 
any procedure, which makes them susceptible to faulty logic ("bugs"). If you 
can achieve the same thing by passing parameters, that's much safer.

-- 
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so 
all may benefit.
date: Mon, 11 Aug 2008 16:19:08 -0400   author:   Jay Freedman

Re: How do I init a variable defined in the Options Explicit area?   
Can't you declare the variable as Public then set it at the beginning of the 
first piece of code that runs in your application. eg the autorun macro



Eddie


> *From:* BearMarquez
> *Date:* Mon, 11 Aug 2008 12:32:01 -0700
> 
> I defined a variable in the Options Explicit area but I need it set to an 
> initial value to it.  This is in WORD 2007 VBA code.
>
date: Mon, 11 Aug 2008 21:22 +0100 (BST)   author:   (Edward Thrashcort)

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us