Results 1 to 2 of 2
2010-06-01, 13:32 #1
- Join Date
- Mar 2003
- Memphis, Tennessee, USA
- Thanked 0 Times in 0 Posts
If anyone could assist me with a simple toggle Macro, when you run it the first time it would set a value in the computer memory anything will do.
First it would preform a function/command after which it would set the memory variable. When the Macor was run again I think using the IF THEN ELSE
it would see the Macro needs to go to the second selection preform the function/command and reset the value to 0 or nothing. Then when the Macro was rung again it would run the first section again and set the value or variable back to something like a 1 ????
Hope you can understand a litte or what I am trying to say?R.J.B. Phillips III
Logical Systems Inc. Part Time Drafter
IBC WONDER HOSTESS Retired 33+ years
Firestone Tr & Rubber Company 15 Years email@example.com
2010-06-01, 15:34 #2
- Join Date
- Feb 2001
- Silicon Valley, USA
- Thanked 93 Times in 89 Posts
In most cases, variables you set in VBA in a host application such as Word are not persistent. However, if you declare a global Public variable (at the top of the module, outside of any Sub or Function), then it should remain in memory as long as the code module itself is active. VBA also has the concept of a Static variable, which retains its value between executions of a procedure, and is private to that procedure. One of these might fit your needs.
For something a bit more permanent, if your host is Word, you could use Document Variables or Document Properties to store a value. Document variables are not visible to the user, so they are fairly safe from tampering, if that is a concern for your application.
I realize this is a very general answer, but hopefully I've gotten you a bit closer to a solution.