查找并从Word文档超链接替换 [英] Find and Replace Hyperlinks from word Document
本文介绍了查找并从Word文档超链接替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的code ....
Microsoft.Office.Interop.Word.Application的applicationObject =新Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document aDDoc = applicationObject.Documents.Open(文件名:文件路径);
Microsoft.Office.Interop.Word.Hyperlinks链接= aDDoc.Hyperlinks;的for(int i = 0; I< links.Count;我++)
{
对象指数=(对象)我;
串c =链接[指数] .TARGET; //这里我得到COM异常,见下文
}
COM异常:内部异常为空,当链接数IAM越来越正确。请告诉我,如果任何一个有想法如何检索超链接URL。
解决方案
串c =链接[I] .TARGET
应该可以正常工作。
Here is my Code....
Microsoft.Office.Interop.Word.Application applicationObject = new Microsoft.Office.Interop.Word.Application();
Microsoft.Office.Interop.Word.Document aDDoc = applicationObject.Documents.Open(FileName: FilePath);
Microsoft.Office.Interop.Word.Hyperlinks links = aDDoc.Hyperlinks;
for (int i = 0; i < links.Count; i++)
{
object index = (object)i;
string c = links[index].Target; //Here i am getting Com exception, see below
}
Com exception: the inner exception is null, Where the link count iam getting correct. Please tell me if any one have the idea how to retrieve the Hyperlink URL.
解决方案
string c = links[i].Target
Should work fine.
这篇关于查找并从Word文档超链接替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文