我有一个Word文档,我想将现有模板附加到。
为了将模板样式设置为文档样式,我必须更新样式。
除模板的页脚外,所有模板定义均已成功更新。
//Opening the document to Word application
Microsoft.Office.Interop.Word.Document wordDoc = null;
Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
object oFileName= MyDocumentPath;
wordDoc= wordApp.Documents.Open(ref oFileName,ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
//Use an existing template
object oTemplate = (object)coverPagePath;
wordApp.ActiveDocument.set_AttachedTemplate(ref oTemplate);
wordApp.ActiveDocument.UpdateStyles();
有什么想法吗?