Problem getting template name

D

DavidSp8

I have a C# .net Automation program that copies a word file locally, it
optionally copies the template file attached as well. Occaisionally, the
program returns the default normal.dot template. However when I look at the
template in word it has the correct name of the template?

My code looks like this;

Template template = (Template)m_doc.get_AttachedTemplate();
return template.FullName;

Any ideas why this code does not always return the template that's attached
to the word document?
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?RGF2aWRTcDg=?=,

The one thing that occurs to me is if the template can't be found. The dialog
box Tools/Templates and Addins shows the original template. But if the template
can't be found in that path, Word attaches Normal.dot. AttachedTemplate returns
the name of the template that's truly attached, not the name of the original
template, stored in Word's binary structure.

In VBA, in the Word object model, I can use the following to pick up what's in
the dialog box. I imagine you can use it from .NET (C#) as well, but I can't
tell you the exact syntax you'd need

Application.Dialogs(wdDialogToolsTemplates).template
I have a C# .net Automation program that copies a word file locally, it
optionally copies the template file attached as well. Occaisionally, the
program returns the default normal.dot template. However when I look at the
template in word it has the correct name of the template?

My code looks like this;

Template template = (Template)m_doc.get_AttachedTemplate();
return template.FullName;

Any ideas why this code does not always return the template that's attached
to the word document?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
D

DavidSp8

You are correct, the template is "not valid". I will try getting the
template name using the method you mention.

Thanks for the help
 

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