Word cannot attach a document to a protected template?

M

Mike

Hi! I am trying to open a blank Word 2003 document based on a custom template.

I am getting "Word cannot attach a document to a protected template" error.

Here's my code:

object missing = System.Reflection.Missing.Value;
Word.ApplicationClass wordApp = new Word.ApplicationClass();
Word.Document newDoc = wordApp.Documents.Add(ref missing, ref missing, ref
missing, ref missing);
newDoc.Range(ref missing,ref missing).Text = "Test";
object templateName = (object)@"C:\MyTemplate.dot";
newDoc.set_AttachedTemplate(ref templateName); // breaks here
wordApp.Visible = true;
 

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