摘要:[.NET C# - Word] 開啟Word檔
以下為 c# 操作 Microsoft.Office.Interop.Word 開啟 word 檔的例子:
01 
using Microsoft.Office.Interop.Word;
02
03
public class WordHelper
04
{
05
private Microsoft.Office.Interop.Word._Document m_Document = null;
06
private Microsoft.Office.Interop.Word._Application m_wordApplication = null;
07
08
public void OpenWordDocument(m_wordTemplatePath)
09
{
10
this.m_wordApplication = new Microsoft.Office.Interop.Word.ApplicationClass();
11
this.m_wordApplication.DisplayAlerts = WdAlertLevel.wdAlertsNone; //不顯示警告或彈跳視窗。如果出現彈跳視窗,將選擇預設值繼續執行。
12
this.m_wordApplication.Visible = false; //背景執行
13
this.m_Document = this.m_wordApplication.Documents.Open(ref m_wordTemplatePath, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
14
}
15
}


02

03

04

05

06

07

08

09

10

11

12

13

14

15
