Loop though body only of an email

不问归期 提交于 2019-12-11 08:55:37

问题


I want to run a macro only affecting the body of the email currently open (e.g., not the signature).

The code below works if the body is selected. How can we do it without need for selecting?

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:


Here is the solution

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


来源:https://stackoverflow.com/questions/31265985/loop-though-body-only-of-an-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!