Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing configuration data in Word

Status
Not open for further replies.

KMillar

Programmer
Oct 16, 2001
18
AU
Hi all,

I need to be able to store file destinations for template documents within Word's normal.dot - without hardcoding them into macros attached to the normal.dot.

This normal.dot is used by a number of users that need to store and retrieve files in different locations, so ideally, they would set up default paths that would be saved when they exit Word. Using this idea, I'd also like to build a custom menu from stored definitions.

It's easy to do in Excel for example, where you just write the info to a hidden sheet, but I have no idea of how to do this in Word.

Hope you can help. Thanks.
 
You could probably use the Custom Properties.

see
Set myRange = ActiveDocument.Content
myRange.Collapse Direction:=wdCollapseEnd
For Each prop In ActiveDocument.CustomDocumentProperties
With myRange
.InsertParagraphAfter
.InsertAfter prop.Name & "= "
.InsertAfter prop.Value
End With
Next

This example adds a custom built-in property to Sales.doc.

thename = InputBox("Please type your name", "Name")
Documents("Sales.doc").CustomDocumentProperties.Add _
Name:="YourName", LinkToContent:=False, Value:=thename, _
Type:=msoPropertyTypeString



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Hi KMillar,

You can use properties (document or custom) to store information if you wish or, if the data are user-specific, you could store them in the registry.

However, I am slightly confused as to what you want.

You say you have a normal.dot used by several people - this is unusual, could you explain a bit more.

You also say you want to store information (but not hard coded) in normal.dot which relates to other .dot templates. Why not store the information in the relevant tempates themselves?

Also you draw a comparison with saving data in a hidden sheet in Excel - would this be in a particular workbook to which all users have access, or in each user's own personal.xls, or what?

And, finally, what exactly do you want on your custom menu abd would it be user-specific and/or document-specific and/or template-specific?

Sorry, just a lot of questions really.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
Thanks guys for the info guys! I'll give your idea a go Frederico and let you know how I get on.
To answer your questions Tony:
1.) This system is used my several company locations that are geographically separed and not networked. The users of the system pull data from Unix box, click their icon that appears whenever Word is started and it looks at the data and uses the first field (Job ID) to match exisiting .docs that start with the Job ID then the name. These docs are templates and the macro populates the required fields and prints them off.

1.) At the moment, the macro reads a text file (path is hardcoded into the macro) that contains the path to where the data will be on their file server. So the way it is now, requires the same directories be created on every machine that will use this - not really ideal - it should be able to be configured when first implemented and to be maintained through forms or whatever in case the server get relocated etc.

3.) With regards to the Excel sheet the way these have been set up in the past is that each user can configure the XLS to suit their own requiremets with regards to where they want the data stored. The menus are not user configurable - just path info. The user has a menu option to set these up through a form. The form stores that info on a hidden sheet.

4.) The menu in the Word system would be the same for all users using this set up, so ideally the .dot would contain the menu definitions. They never actuall interact with the template docs directly - only the macro uses them.

Hope I've answered your questions, and thanks again for your help guys.
 
Hi KMillar,

Thanks for the answers.

If I read you right, what you call templates are actually documents, and when you say a number of users use the same normal template, you mean they are each given a copy of it.

Normal.dot is not the ideal location for this kind of thing, and a separate global template would be better. Whichever you use, you still need somewhere to store your data and attaching to a document (or a template) isn't really suitable for user-specific data - I suggest you use the registry - take a look at [blue]GetSetting[/blue] and [blue]SaveSetting[/blue] for how to do this.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
I agree with Tony's suggestion, but using a Word document is also fine.

But as you are going to need to code, and if your users ALL have Excel, then you may also consider to keep the variables on an Excel spreadsheet, or on a .MDB file (Access, but runtime not required), common to all of your documents.



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
I agree with TonyJ that normal.dot is not the best location. Every once in a while Word decides that normal.dot is corrupted, and does weird stuff.

Create a separate .dot file. You can handle distribution by creating a .doc file with all the macros you need the will save itself as a .dot via macros triggered by AutoOpen.

Save whatever data you need in an .ini file. Distribtion process could create this as will (although that would require having it coded in the macro that creates the file)
 
Thanks everyone for your help. I'll be back on the job Tuesday and hopefully get something happening with this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top