word to txt文件转换,如何忽略thw异常错误 [英] word to txt file conversion,how to ignore thw exception error

查看:98
本文介绍了word to txt文件转换,如何忽略thw异常错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Word.Document doc = Globals.ThisAddIn.Application.ActiveDocument;

doc.SaveAs2(FileName: Path.GetDirectoryName(doc.FullName) + Path.GetFileNameWithoutExtension(doc.Name) + ".txt",FileFormat:Word.WdSaveFormat.wdFormatText);







将word文件转换为txt文件时显示异常 COM EXCEPTION未被用户代码处理命令失败如何解决它

推荐答案

这是调试的机会,请参阅文档 [ ^ ]。
This is a chance for debugging, see The Documentation[^].


您可以将调用包装在try-catch块中。但我不建议吞下(即忽略)execption - 更好地获取COM异常代码及其与Word Interop的含义,最终摆脱失败的原因。
You could wrap the call in a try-catch block. But I do not recommend to swallow (i.e. ignore) the execption - better get the COM exception code, and its meaning with Word Interop, to eventually get rid of the reason of failure.


这篇关于word to txt文件转换,如何忽略thw异常错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆