分享

System.Runtime.InteropServices.COMException (0x800A141F): Word 无法读取文档,文档可能损坏。

 实力决定地位 2015-07-14
以下是我写的创建一个word并打开,为了方便转换用的
#region 文件格式转换
//请引用Microsoft.Office.Interop.Word
ApplicationClass word = new ApplicationClass();
Type wordType
= word.GetType();
Documents docs
= word.Documents;

// 打开文件
Type docsType = docs.GetType();
object fileName = wordPath; //"f:\\cc.doc";
Document doc = (Document)docsType.InvokeMember("Open", BindingFlags.InvokeMethod, null, (object)docs, new Object[] { fileName, true, true });
在执行到
Document doc = (Document)docsType.InvokeMember("Open", BindingFlags.InvokeMethod, null, (object)docs, new Object[] { fileName, true, true });
抛出异常:
System.Runtime.InteropServices.COMException (0x800A141F): Word 无法读取文档,文档可能损坏。
请尝试下列方法:
* 打开并修复文件。
* 用文本恢复转换器打开文件。

根据网上搜索InvokeMember方法用法在msdn上看到它的运行平台支持
Windows 7, Windows Vista SP1 或更高版本, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008(不支持服务器核心), Windows Server 2008 R2(支持 SP1 或更高版本的服务器核心), Windows Server 2003 SP2
InvokeMember方法说明:http://msdn.microsoft.com/zh-cn/library/system.reflection.ireflect.invokemember.aspx
我的服务器系统为Windows Server 2008 64位。看到这儿知道是系统问题,
于是在网上搜索,终于找到一篇文章写的和我问题一样得到解决方法
如果系统为Windows 2008 Server x64
在下面路径中创建一个Desktop空的文件夹
C:\Windows\SysWOW64\config\systemprofile\Desktop
如果系统为Windows2008Serverx86
在下面路径中创建一个 Desktop空的文件夹
C:\Windows\System32\config\systemprofile\Desktop

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多