I am trying to write a macro for Outlook (I never wrote a macro, or VBA, for that matter), which will remove the space before and after the text that I selected.
Here is what I compiled from the examples I found:
Sub FixParagraphSpacing() Dim objOL As Application Dim objDoc As Object Dim objSel As Object Set objOL = Application Set objDoc = objOL.ActiveInspector.WordEditor Set objSel = objDoc.Windows(1).Selection objSel.ParagraphFormat.SpaceBefore = 0 objSel.ParagraphFormat.SpaceAfter = 0 Set objOL = Nothing Set objDoc = Nothing Set objSel = Nothing End Sub
The problem is that the code is executing, and almost nothing is happening. The body of the message is not affected, but I cannot remove the before and after interval manually, because Outlook believes that this has already been done.
What am I missing here?
Update
Here is my updated code based on @KevinPope answer:
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 para.SpaceAfter = 0 Next para End Sub
Before I run the code, here is what I see under Line Spacing:

And here is what I see after running the macro:

Unfortunately, besides this, there are no visible changes in the body of the letter .
Screenshot with text for request:

source share