Office操作出现进程在系统中不能关闭而出错, 另一个进程正在使用此文件
来源:互联网 发布:windows 8.1 WIFI 编辑:程序博客网 时间:2024/06/05 04:36
Microsoft.Office.Interop.Word._Application wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
Microsoft.Office.Interop.Word._Document wordDoc = null;
try
{
//打开Word文档对象
wordDoc = wordApp.Documents.Open(ref filename, ref confirmConversions, ref readOnly, ref addToRecentFiles, ref passwordDocument, ref passwordTemplate, ref revert, ref writePasswordDocument, ref writePasswordTemplate, ref format, ref encoding, ref visible, ref openConflictDocument, ref openAndRepair, ref documentDirection, ref noEncodingDialog);
wordDoc.AcceptAllRevisions(); //接收word中所有的修订
wordDoc.Save();//保存
wordDoc.Close(ref missing, ref missing, ref missing);
wordApp.Application.Quit(ref saveOption, ref missing, ref missing);
}
catch { }
finally
{
//杀死打开的word进程
Process myProcess = new Process();
Process[] wordProcess = Process.GetProcessesByName("winword");
try
{
foreach (Process pro in wordProcess) //这里是找到那些没有界面的Word进程
{
IntPtr ip= pro.MainWindowHandle;
string str = pro.MainWindowTitle; //发现程序中打开跟用户自己打开的区别就在这个属性
//用户打开的str是文件的名称,程序中打开的就是空字符串
if (string.IsNullOrEmpty(str))
{
pro.Kill();
}
}
}
catch (Exception ex)
{
ex.ToString();
}
}
}
- Office操作出现进程在系统中不能关闭而出错, 另一个进程正在使用此文件
- IIS中另一个程序正在使用此文件,进程无法访问
- IIS建立新网站出错-另一个程序正在使用此文件,进程无法访问
- IIS建立新网站出错-另一个程序正在使用此文件,进程无法访问
- IIS错误信息--另一个程序正在使用此文件,进程无法访问!
- IIS另一个程序正在使用此文件,进程无法访问
- iis提示“另一个进程正在使用此文件,无法访问”解决方法
- IIS错误信息--另一个程序正在使用此文件,进程无法访问
- iis提示“另一个程序正在使用此文件,进程无法访问”
- iis提示“另一个程序正在使用此文件,进程无法访问”
- IIS错误信息--另一个程序正在使用此文件,进程无法访问!
- IIS错误信息--另一个程序正在使用此文件,进程无法访问!
- 另一个程序正在使用此文件,进程无法访问
- IIS出现“另一个程序正在使用此文件,进程无法访问。”错误提示的解决办法
- 启动IIS 网站出现错误 另一个程序正在使用此文件,进程无法访问
- 启动IIS 网站出现错误 另一个程序正在使用此文件,进程无法访问
- VS调试出现错误提示 无法将“obj\Debug\*.*”复制到“bin\Debug\*.*”,文件正在由另一个进程使用,因此该进程无法访问此文件
- 启用休眠时提示:另一个程序正在使用此文件,进程无法访问的解决办法。
- 堆和栈的区别
- JNDI知识
- UVA10010- Where's Waldorf?(string+暴搜)
- C++学习笔记---继承
- oracle常用建表空间,用户,导入导出命令
- Office操作出现进程在系统中不能关闭而出错, 另一个进程正在使用此文件
- 我的第一个JSP
- 2013/1012一个引脚输出PWM信号,一个引脚接收输入——驱动的构思
- Java遍历文件夹的2种方法:
- java注解应用-java.lang.annotation
- 中国天气网API
- Myeclipse下ext插件spket的配置和安装
- VC++ 实现soap服务端
- MemcacheD、Repcached在centos上的安装步骤