循环通过电子邮件的正文

时间:2015-07-07 10:25:41

标签: vba outlook-vba outlook-2010

我想运行一个仅影响当前打开的电子邮件正文的宏(例如,不是签名)。

如果选择了正文,则下面的代码有效。我们如何在不需要选择的情况下完成?

Sub FixParagraphSpacing()

    Dim objOL As Application
    Dim sel As Object

    Set objOL = Application
    Set sel = objOL.ActiveInspector().WordEditor.Application.Selection

    For Each para In sel.Paragraphs
        para.SpaceBefore = 0.3 * 11
        para.SpaceAfter = 0
    Next para

End Sub

1 个答案:

答案 0 :(得分:0)

这是解决方案

Sub FixParagraphSpacing()
     Dim objOL As Application
     Dim doc As Object
     Dim para As Object

     Set objOL = Application
     Set doc = objOL.ActiveInspector().WordEditor

     For Each para In doc.Paragraphs
         para.SpaceBefore = 0.3 * 11
         para.SpaceAfter = 0
     Next para
 End Sub