我喂多个文档到下面的方法,看WINWORD.EXE disapear上运行32位的WinXP对Win8的64位有办公室2000年起超过15 diferente电脑预期。在已公布的反病毒软件运行,WINWORD.EXE 1个噩梦PC(常亮,每次)中断循环与异常的“文件正在使用”(打开关闭的趋势使其重新工作)。任何保持趋势的想法?c#interop winword.exe不退出()!
void loop()
{
Microsoft.Office.Interop.Word._Application app = new Microsoft.Office.Interop.Word.Application();
app.Visible = false; app.ScreenUpdating = false; app.DisplayAlerts = WdAlertLevel.wdAlertsNone;
Microsoft.Office.Interop.Word._Document doc = app.Documents.Open(FilePath, false, true, false);
doc.Activate(); doc.DisableFeatures = true;
doc.ExportAsFixedFormat(newFileName, WdExportFormat.wdExportFormatPDF, false,WdExportOptimizeFor.wdExportOptimizeForOnScreen, WdExportRange.wdExportCurrentPage, 1, 1, WdExportItem.wdExportDocumentWithMarkup, false, false, WdExportCreateBookmarks.wdExportCreateNoBookmarks, true, false, true, Type.Missing);
((Microsoft.Office.Interop.Word._Document)doc).Close(WdSaveOptions.wdDoNotSaveChanges);
Marshal.ReleaseComObject(doc);
Marshal.FinalReleaseComObject(doc);
((Microsoft.Office.Interop.Word._Application)app).Quit(WdSaveOptions.wdDoNotSaveChanges);
Marshal.ReleaseComObject(app);
Marshal.FinalReleaseComObject(app);
GC.GetTotalMemory(false);
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.GetTotalMemory(true);
}
鲁克,你摇滚。我完全按照你所描述的每次完美的执行。谢谢! –