Microsoft.Office.Interop.Word を使用して IIS 経由で Web アプリケーションを実行しようとすると、Word テンプレート 2007 を編集できません。しかし、開発環境では正常に動作しています。以下は私のコードサンプルです、
using Word = Microsoft.Office;
object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */
Object oTrue = true;
Object oFalse = false;
//Start Word and create a new document.
Word.Interop.Word.Application oWord = new Word.Interop.Word.Application();
Word.Interop.Word.Document oDoc;
oWord.Visible = true;
//Using Template format of the existing Word Doc
object oTemplate = "C:\\MyTemplate.dotx";
oDoc = oWord.Documents.Add(ref oTemplate, ref oMissing,
ref oMissing, ref oMissing);
//Get the Bookmark location from Template Document
Word.Interop.Word.Table wTbl = oDoc.Bookmarks.get_Item("Test").Range.Tables[1];
IIS oDoc を実行しているときに null として送信され、オブジェクトを確認しましoWord
た。System._Comobject
Microsoft.Office.Interop.Word