选择并标记 Word 文档中的特定格式

发布于 2024-08-08 03:29:21 字数 393 浏览 1 评论 0原文

需要将 DOC 文件导出到 TXT,然后在不丢失粗体和下划线格式的情况下重新导入它,我需要一个宏来做到这一点。

我的想法是选择每组粗体单词(可以是一个句子或句子中的单个单词),然后在其前面写上 <$><$$> ; 之后。当回到单词时,应该发生相反的情况,即 <$><$$> 之间的所有文本都恢复为粗体。相同的宏适用于下划线和粗体+下划线。我尝试将 doc 导出为 html,然后在 html 编辑器中打开并另存为 txt,仅保存粗体和下划线标记。完美,如果不是编辑器在每行末尾添加的 CR LF...

TIA,我的宏编程技能缺乏基本的...

alberto

being in need to export a DOC file to TXT and then reimport it without losing bold and underline formatting I'd need a macro to do that.

My idea is to select each group of words in bold (could be a sentence or a single word in sentence) and then write say <$> before it and <$$> after it. When back in word the reverse should happen, i.e. all text between <$> and <$$> back to bold. The same macro works for underline and bold+underline. I tried to export doc to html, then open in an html editor and save as txt saving only the bold and underline tags. Perfect, if not for the CR LF that the editor puts at the end end of each line...

TIA, my macro programming skills are short of basic...

alberto

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

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

发布评论

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

评论(1

绾颜 2024-08-15 03:29:21

您能否提供一些原始文件和您处理的文件的示例文档?如果只是关于 CR 和 LF,可以通过 VBA 替换它们:

textasstring = Replace$(textasstring, vbCrLf, "")
textasstring = Replace$(textasstring, vbLf, "")

另一个解决方案是采用一个能够支持扩展搜索和替换的编辑器,包括 \r 和 \n,如 notepad++。

Could you provide some example document for the original file and file you processed? If it is only about CR and LF, you can replace them via VBA:

textasstring = Replace$(textasstring, vbCrLf, "")
textasstring = Replace$(textasstring, vbLf, "")

Another solution is to take an editor which is able to support extended search and replace including \r and \n like notepad++.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文