如何以编程方式在整个 Word 文档中查找和替换

发布于 2024-08-04 14:08:31 字数 248 浏览 1 评论 0原文

我有一个Word文档,其中有表格内的文本和表格外的文本。我想查找并替换所有文本,而不仅仅是表格外的文本。文档的内容属性只是“主要故事”,而不是表格。我不想遍历所有表对象。我只想在所有文本中查找和替换,就像我使用 Word gui 手动执行操作一样。

请把我从正在燃烧的精神地狱中拯救出来。

[肉体燃烧的恶臭开始让我担心。几乎和我四肢的剧痛一样强烈。]

[我的腿和手臂都被火焰吞噬了。我用鼻子写下这些,鼻子上粘着按键上融化的塑料。]

I have a Word document with text in tables and text outside tables. I want to find and replace in all the text, not just the text outside the tables. The content property of the document is just the "main story" and not the tables. I don't want to iterate through all the table objects. I just want to find and replace in all the text, just like when I do it manually using the Word gui.

Please save me from the mental hell I am burning in.

[The stench of burning flesh is starting to worry me. Almost as much as the excruciating pain in my extremities.]

[My legs and arms have been devoured by the flames. I write this with my nose, which is sticky with melted plastic from the keys.]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最偏执的依靠 2024-08-11 14:08:31

使用Find属性,它与UI相同。搜索“查找属性”的帮助主题以帮助您入门。

With ActiveDocument.Range.Find
    .Text = "hi"
    .Replacement.Text = "hello"
    .Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
End With

Use the Find property, it is the same as the UI. Search help topic for "Find Property" to get you started.

With ActiveDocument.Range.Find
    .Text = "hi"
    .Replacement.Text = "hello"
    .Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
End With
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文