1
votes

I have written several applications in Delphi which use Word automation. The programs all use templates which are stored in a directory. In pre-2010 versions of Word, one would define the location of the templates in tools|options|file locations; the programs would pass the name of the template and Word would know where to find it.

My client has now moved to Office 2010, and as a result, Word cannot find the template when started by my programs. I haven't been able to find a similar dialog box in Word in which I can define the default directory for templates. How does one define such a directory?

4
I should have added the fact that several computers have to access the templates and so they are stored on a shared network drive. Storing the templates on each user's computer is not an option if I have to update them.No'am Newman

4 Answers

3
votes

Click File | Options | Advanced | File Locations and you get the same dialog as in older verionsalt text

1
votes

Instead of forcing your user to configure Word to define the location of templates, you might prefer to invoke word using /t switch.

/ttemplatename starts Word with a new document based on a template other than the Normal template.

>"%programfiles%\Microsoft Office\Office14\winword.exe" /t"c:\MYTEMPLATES\mytemplate.dotx"
1
votes

Can't you just specify the full path when creating a new document? Why rely on a settings that possibly can even be changed by the user? Put your templates in your own folder and specify the full path.

1
votes

Word's paths configuration are stored

You can get the USER template folder via

Word.Application.Options.DefaultFilePath(WdDefaultFilePath.wdUserTemplatesPath)

(there are others options for that property too).

As far as I can tell, the template loading rules haven't changed from 2007 to 2010.

Generally speaking, if your add in needs to load a template, you should specify the FULL path and file name to the template, but you can get the typical user path via the above.

On the other hand, if you install the template into WORD\STARTUP, word will automatically load it. that may not be what you need/want, though.

Finally, if your template doesn't/shouldn't change, it might be better to leave it in your PROGRAM FILES\appname folder and load it from there.

Generally speaking, +requiring+ users to change the FILE LOCATIONS in word (or changing it programmatically) is a bad idea, just because so many people wouldn't have a clue, and those that do definitely DO NOT want addins changing those settings automatically!