Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

Storing variable data in document

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike Starr - 26 Nov 2005 11:00 GMT
I've created a template that presents a user form. The form has a text field
that the user enters a filename. I use this filename and another variable to
construct the name that the document will be saved as.

I need to store the user-entered name in the saved document along with the
other variable so that if a user opens a previously saved document based on
this template, I can retrieve those variables.

How does one store a variable so that it will persist in the saved document
for later retrieval??

Thanks

Mike

--
Mike Starr                            WriteStarr Information Services
Technical Writer  -  Online Help Developer  -   Technical Illustrator
Graphic Designer    -    Desktop Publisher   -       MS Office Expert
(262)  694-1028  -  mike@writestarr.com  -  http://www.writestarr.com
Helmut Weber - 26 Nov 2005 11:29 GMT
Hi Mike,

you may use a document variable,
like this:

Dim sVar As String
sVar = "testvar"
With ActiveDocument.Variables
  .Item("MyName").Value = sVar
  MsgBox .Item("MyName").Value ' testing
End With

Creates the variable, if doesn't exist,
and sets the value, otherwise, just sets the value.

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

ML - 26 Nov 2005 11:30 GMT
Save it in a custom document property.

> I've created a template that presents a user form. The form has a text
> field that the user enters a filename. I use this filename and another
[quoted text clipped - 16 lines]
> Graphic Designer    -    Desktop Publisher   -       MS Office Expert
> (262)  694-1028  -  mike@writestarr.com  -  http://www.writestarr.com
Mike Starr - 26 Nov 2005 19:10 GMT
Thanks to both Helmut and ML... you've pointed me in the right direction.
Now that I know what to look for, I've found the appropriate topics in the
VBA help file.

Mike

> I've created a template that presents a user form. The form has a text
> field that the user enters a filename. I use this filename and another
[quoted text clipped - 16 lines]
> Graphic Designer    -    Desktop Publisher   -       MS Office Expert
> (262)  694-1028  -  mike@writestarr.com  -  http://www.writestarr.com

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.