Z
zfeld
I am trying to retrieve a my custom template from the word template
folder using C# however my code seems to only find normal.dot. When I
look at the directory in explorer my template is there. I can retrieve
it if I specify a path to the file,but not using word.templates, which
is what I need. What am I doing wrong. I am new to office automation
so bear with me if it is obvious
//Start Word and create a new document.
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
string templatePath = "";
foreach(Word.Template CurTemplate in oWord.Templates)
{
if (CurTemplate.Name == "My Report.dot")
{
templatePath = CurTemplate.FullName;
break;
}
}
if(templatePath.Length == 0)
return;
object oTemplate = templatePath;
oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing,ref oMissing,
ref oMissing);
folder using C# however my code seems to only find normal.dot. When I
look at the directory in explorer my template is there. I can retrieve
it if I specify a path to the file,but not using word.templates, which
is what I need. What am I doing wrong. I am new to office automation
so bear with me if it is obvious
//Start Word and create a new document.
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
string templatePath = "";
foreach(Word.Template CurTemplate in oWord.Templates)
{
if (CurTemplate.Name == "My Report.dot")
{
templatePath = CurTemplate.FullName;
break;
}
}
if(templatePath.Length == 0)
return;
object oTemplate = templatePath;
oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing,ref oMissing,
ref oMissing);