【问题标题】:Microsoft Word / Outlook trims leading spaceMicrosoft Word / Outlook 修剪前导空格
【发布时间】:2023-07-22 10:49:01
【问题描述】:

我通过 Outlook 将 SQL 作为 HTML 发送给感兴趣的各方,并使用 Word 作为编辑器。

我喜欢使用空格而不是制表符来格式化我的 SQL。

当我将 SQL 粘贴到编辑器中时,格式是正确的。 但“已发送”版本删除了前导空格。

例如:

Select
 *
From
 Employees

变成

Select
*
From
Employees

有没有办法防止这种情况发生?

【问题讨论】:

  • 有谁知道如何解决这个问题??

标签: html ms-word outlook editor trim


【解决方案1】:

我没有找到解决方案,但找到了解决方法 - 将所有(且仅)前导空格替换为 非破坏性空格。无需替换所有空格,只需替换前导空格。这样 Outlook 在发送电子邮件时不会自动修剪它们。

发送邮件前需要

  1. 选择要保留前导空格的文本,然后运行查找和替换 (Ctrl+H)
  2. 输入查找内容:"^p "(插入符号、p、空格)或点击底部的[特殊]按钮并选择段落标记 只是一个空格字符
  3. 输入替换为:"^p^s"(插入符号,p,插入符号,s)或点击底部的[特殊]按钮并选择段落标记不间断空间
  4. 现在按 [全部替换] - 它将仅在选定文本中将前导空格替换为 不间断空格,其余所有文本保持不变。

带有前导空格的结果:

First without leading spaces
One leading space in this row
No leading spaces again
One leading space in this row
  Two leading spaces here
One leading space in this row
No leading spaces again
One leading space in this row
  Two leading spaces here
  Two leading spaces here
One leading space in this row
  Two leading spaces here
  Two leading spaces here
   Three leading spaces here

前导不间断空格:

First without leading spaces
 One leading space in this row
No leading spaces again
 One leading space in this row
  Two leading spaces here
 One leading space in this row
No leading spaces again
 One leading space in this row
  Two leading spaces here
  Two leading spaces here
 One leading space in this row
  Two leading spaces here
  Two leading spaces here
   Three leading spaces here

【讨论】:

  • 大声笑 - 神圣的地狱,但哦,我的,我的,我的,我的,我的天啊,要实现的混乱集群。假设现在是为 Word 编写宏的好时机!再次感谢:)
  • 老兄!其他人怎么能发现这个解决方案有用??? !!!! ??? !!!我发现自己几乎每天都在使用它——我仍然不知道如何使它成为一个宏!!!
  • 我们忘记投票了。我几乎是自己做的!为我感到羞耻,感谢您的提醒。不幸的是,我讨厌这个解决方案,但这不是科斯塔斯的错。
【解决方案2】:

简介:以纯文本形式发送电子邮件以保留空格。

在花费太多时间尝试(但失败)覆盖 HTML 段落样式、覆盖列表样式/字符以及调整 Outlook 2013 中的自动套用格式设置之后,后备解决方案可能是发送任何重要的电子邮件将空格保留为纯文本。

可以通过以下方式以纯文本形式发送电子邮件:

  1. 选择“设置文本格式”功能区选项卡。
  2. 在“格式”组中选择纯文本。

【讨论】:

  • 感谢您的回复。是的,我知道你对这件事变成浪费时间的活动的感受。