C#打开并修复word实现方法
C#打开并修复word实现方法
C#操作打开损坏的word时候,可以采用如何方法进行打开,如下:
objDocLast = objApp.Documents.Open(
ref objOrgDoc, //文件名
ref objMissing, //确认版本
ref objMissing, //只读
ref objMissing, //添加到最近的文件
ref objMissing, //密码文件
ref objMissing, //密码摸板
ref objMissing, //回复
ref objMissing, //写密码文件
ref objMissing, //写密码摸板
ref objMissing, //格式
ref objMissing, //加密
ref objMissing, //可视
ref objMissing, //打开并修复
ref objMissing, //直接文党
ref objMissing, //没加密的对话框
ref objMissing //XML传输
);
#region - 打开并修复文档 -
public static bool OpenAndRepair(string filePath, bool isVisible)
{
try
{
oWord = new Microsoft.Office.Interop.Word.Application();
oWord.Visible = isVisible;
object path = filePath;
oDoc = oWord.Documents.Open(ref path,
ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing,
ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing,
ref Nothing, true, ref Nothing, ref Nothing, ref Nothing);
return true;
}
catch (Exception)
{
return false;
}
}
#endregion