Incorrect templates path

V

VanS

Hello,
I have a VB6, Excel/Word VBA app that runs in Excel and uses the
Application.TemplatesPath property to locate where the templates I created
and stored are-this is the same folder where the standard Word and Excel
templates are located. It works fine under Win XP pro and Office 2003, but in
a testbed under Virtual PC 2004 that is Win 98, Office 97 it grabs the wrong
location.
The correct location under that system should be:
C:\Windows\Application Data\Microsoft\Templates\
but instead it grabs:
C:\Program Files\Microsoft Office\Templates\
This was originally developed under Office 97 before I upgraded and I
believe I used the same code and it worked before.
Any ideas on what the problem is and how to resolve this?
Thanks, God bless
Van
 
T

Tom Winter

The "correct" template path under Word 97 is under Program Files. I believe
Word did not start using the Application Data path until Word 2000. I have
BOTH Word 97 and Word 2000 installed on the same system, and 97 looks in the
Program Files path and 2000 looks in the App Data path. The
Application.TemplatePath will return what ever is set in TOOLS | OPTIONS |
FILE LOCATIONS | USER TEMPLATES. If you look under Word 97, you'll see it's
set to Program Files. The user would have to change this to use the App Data
path. Also remember that even under any version of Word, the user may have
changed their Templates path from the default. When installing your
templates you should attempt to determine what version of Word is installed
and then install your templates in the appropriate location.

This KB article talks about determining the template path for Word 97:
http://support.microsoft.com/default.aspx?scid=kb;en-us;173603

This should help with Word 2000
http://support.microsoft.com/default.aspx?scid=kb;en-us;212242

Word 2002/XP
http://support.microsoft.com/default.aspx?scid=kb;en-us;291141

Word 2003
http://support.microsoft.com/default.aspx?scid=kb;en-us;889495

Note that is looks like for 2000 an up, the registry entry is NOT there if
the path has not been changed from it's default.
 
V

VanS

Thanks Tom for your reply.
I am thinking perhaps the simplest solution is to do as one respondent said,
to just put my Word and Excel templates in my Program Files\Application
folder. I have Word templates and also Excel workbook and worksheet
templates. For the Word .dot and Excel Workbook templates I can then set the
path in the code. The only problem I am having now is trying to use the add
method of the Worksheet to add the worksheet template to a workbook.
The MS website doesn't give very specific instructions for adding a sheet as
a template. I have tried to add from my template after the last sheet such as:
Worksheets.Add.Move (after:=
Worksheets(Worksheets.Count),Type:="C:\Path\TEmplateName.xlt")
and also
Worksheets.Add.Move Type:="C:\Path\TEmplateName.xlt"

However, I get error Application-defined or object-defined error message.
Any idea what the right syntax is to get this done.
Thanks again,
Van
 
T

Tom Winter

Sorry, I don't know anything about the Excel object model. You should try
asking this specific question in an Excel newsgroup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top