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.
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.
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. >