Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Word, PowerPoint, Outlook, and Other Office Products > Save value of variable in Word for next use


Reply
 
Thread Tools Display Modes
  #1  
Old 07-28-2003, 09:24 AM
Angelus Angelus is offline
Freshman
 
Join Date: May 2003
Posts: 37
Default Save value of variable in Word for next use


I want to save the value of my variable that is inside Word's macro. When this document open next time I can use that value again. Can I do that? Can I attach the value in Word file itself?
For example I have variable X and before closing document X is equal 5. When I open the document next time X is still equal 5.
Reply With Quote
  #2  
Old 07-29-2003, 07:08 AM
MrCoder MrCoder is offline
Newcomer
 
Join Date: Jun 2003
Posts: 20
Default Yes. Store Variables in the Document Object

Yes, the Word Application let's you store variables in word. Look it up in VBA the help is pretty robust. Here's the basic idea

Word has document variables that are stored within the document object. Here are the steps.

1) Declare the Variable in your subroutine.

2) Add the variable and value of the variable to the document.
(ActiveDocument.Variables.Add "VariableName", VALUE)
(i.e. ActiveDocument.Variables.Add "wVarLessonName", "Claims Clearance")

3) Return the Value of the Document Variable
Result= ActiveDocument.Variables("VariableName")
Msgbox Result
__________________
cya! m.c

.:| Visualize Whirled Peas |:.
Reply With Quote
  #3  
Old 07-29-2003, 12:02 PM
Skeletal Skeletal is offline
Newcomer
 
Join Date: Jul 2003
Location: Nr. Birmingham, UK
Posts: 21
Default

Check out my post “Word corrupts variables”! I would love you to try to save your variables to see if you get them corrupted as well! Coming back for a look today, sadly (for me) no-one has managed to find me an answer to this problem yet!

Skeletal
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Standards and Practices loquin Tutors' Corner 10 07-28-2006 12:16 PM
Save word file (with images) as binary/hex skinny monkey General 1 06-11-2003 02:25 PM
Close a word document without save kalia Word, PowerPoint, Outlook, and Other Office Products 2 03-21-2003 08:08 AM
Pass variable from word to VB pells2 Word, PowerPoint, Outlook, and Other Office Products 1 09-26-2002 09:11 AM
Word Macro VB - Global Variable??? simonsays Word, PowerPoint, Outlook, and Other Office Products 1 05-27-2002 05:37 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->