日期:2014-05-20 浏览次数:20976 次
ApplicationClass WordApp;
bool isOpened = false;//判断word模版是否被占用
Document WordDoc;
object missingValue = System.Reflection.Missing.Value;
object myTrue = false; //不显示Word窗口
WordApp = new ApplicationClass();
WordApp.Visible = false;
try
{
while (isOpened)
{
System.Threading.Thread.Sleep(500);
}
object oTemplate = (object)filePath;
WordDoc = WordApp.Documents.Open(ref oTemplate, ref missingValue,
ref myTrue, ref missingValue, ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue,
ref missingValue, ref missingValue, ref missingValue,
ref missingValue);
isOpened = true;
WordDoc.Activate();
}
catch (Exception Ex)