从VB.net中删除单词中的一行 [英] delete a line in word from VB.net

查看:105
本文介绍了从VB.net中删除单词中的一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个从word文档中删除一行的功能。我想从VB.net这样做。

我试过:

Hi, i''m looking for a function to delete one line from a word document. I want to do this from VB.net.
I tried:

Do While WordDoc.Content.Find.Execute(FindText:="%NP6%", Wrap:=Word.WdFindWrap.wdFindContinue) = True
           WordApp.Selection.Range.Bookmarks("\line").Range.Delete()
Loop



不删除一行,而是删除文档的完整第一部分,包括%NP6%的行。

任何想法,谢谢,Rob


Instead of deleting one row it deletes the complete first part of the document, including the line with %NP6%.
Anyone an idea, Thanks, Rob

推荐答案

你在这里做的是删除行,而NP6%仍然在你的文档中找到。因为你一个接一个地删除行所以难怪所有的行都被删除,直到%NP6%的行被删除。删除%NP6%后,删除将停止。

相反,您应该尝试循环使用WordDoc.Content的句子并检查文本属性。如果它包含%NP6%将其删除。
What you''re doing here is deleting lines while NP6% is still found in your document. Since you''re deleting lines one by one it''s no wonder all the lines up until the line with %NP6% are deleted. Once %NP6% is deleted the deleting will stop.
Instead you should try looping through the Sentences of WordDoc.Content and check the Text Property. If it contains %NP6% delete it.


这篇关于从VB.net中删除单词中的一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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