问题
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