View Single Post
 
Old 11-25-2022, 05:58 PM
harry harry is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: Jul 2010
Posts: 31
harry is on a distinguished road
Default Macro not working

1. I created the following simple macro in Word, to remove space before and after paragraphs in a document.

Code:
Sub ClearParagraphSpacing()
Selection.WholeStory
With Selection.ParagraphFormat
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
End With
End Sub
This works fine in Word, but when I copy it into Outlook, I get an error when I run it on a new email or a reply: "Object variable or With block variable not set." How can I fix this?

2. I can add a shortcut for the macro on the Ribbon or the Quick Access Toolbar, but when I click on it, nothing happens. However, as the macro needs to work in a message editing window (not in the main folder window), does it need a different kind of shortcut?
Reply With Quote