Passing variables 
Author Message
 Passing variables

Is it possible to pass a variable between projects? My
specific problem is that I set a value in the AUTOEXEC
macro when Normal.dot loads, but then the user runs a
variety of macros to load other templates. These secondary
templates need to read the value of the variable, but when
I check it, it is blank.

Any ideas, please

Thanks

Mike



Tue, 06 Dec 2005 00:51:52 GMT  
 Passing variables
Hi Mike:

It IS possible.  I do that a  lot with global template variables, not
Normal.dot variables, but don't see why it would not work with a Normal.dot
variable.

Here is one way.

1. Declare the Normal.dot variable as a public variable (in the declarations
section of the code module)

e.g. Public sTest as String

2. Edit the VBA projects that must read the variable:-  set a VBA reference
to the normal project.  (You might be able to skip this step for
Normal.dot...I'm not sure, maybe someone else has that answer).  To do that,
go to Tools - References in VBA Editor and check the normal project.

3.  Whenever you refer to the variable in the macro projects, precede it
with Normal.dot's VBA project name "Normal."),

e.g.  Msgbox Normal.sTest

If developing for multiple users, you should test to make sure that the VBA
reference holds up under varying locations of normal.dot.  It should ... the
reference hold up for varying locations for global templates, so same should
happen for normal.dot.

Watch out for run-time errors!  Depending on where the run-time error
occurs, your variable may be erased and not be reliable.

Hope this helps,

Regards,
Jean


Quote:
> Is it possible to pass a variable between projects? My
> specific problem is that I set a value in the AUTOEXEC
> macro when Normal.dot loads, but then the user runs a
> variety of macros to load other templates. These secondary
> templates need to read the value of the variable, but when
> I check it, it is blank.

> Any ideas, please

> Thanks

> Mike



Tue, 06 Dec 2005 09:23:30 GMT  
 Passing variables
Hi Mike,

I would store the information in an ini or text file using the
SystemPrivateProfileString.

For an example of its use, see the article "Creating sequentially numbered
documents (such as invoices)" at:

http://www.mvps.org/word/FAQs/MacrosVBA/NumberDocs.htm

Please respond to the newsgroups for the benefit of others who may be
interested.

Hope this helps
Doug Robbins - Word MVP

Quote:
> Is it possible to pass a variable between projects? My
> specific problem is that I set a value in the AUTOEXEC
> macro when Normal.dot loads, but then the user runs a
> variety of macros to load other templates. These secondary
> templates need to read the value of the variable, but when
> I check it, it is blank.

> Any ideas, please

> Thanks

> Mike



Tue, 06 Dec 2005 11:15:24 GMT  
 Passing variables
Declare a public variable in ThisDocument section of yr document/template

Example:
I've declared a variable in Doc1.doc in ThisDocument module like
Public sPerry As String
It's given a value in Document_Open()

Now calling the variable from other templates would be a matter of:
    Dim d As Document
    Set d = Documents.Open _
        ("d:\MyDocs\Word\Test\Doc1.doc")

    MsgBox d.sPerry
    d.Close
    Set d = Nothing

Krgrds,
Perry



Quote:
> Is it possible to pass a variable between projects? My
> specific problem is that I set a value in the AUTOEXEC
> macro when Normal.dot loads, but then the user runs a
> variety of macros to load other templates. These secondary
> templates need to read the value of the variable, but when
> I check it, it is blank.

> Any ideas, please

> Thanks

> Mike



Wed, 07 Dec 2005 16:17:18 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Passing Variables

2. Passing variables

3. Passing Variable Names

4. Passing Variables Back And Forth From Access To Word

5. Problems Passing Variables

6. Passing variables to reports.

7. Pass variable to a query

8. Passing variables from separate table to VBA

9. Help - Passing Variables from Table or Query

10. passing variables to openform where clause

11. Passing Variables to subroutines

12. passing variables between class modules

 

 
Powered by phpBB® Forum Software