Friday, February 20, 2015

Outlook macro to change "style set" on reply


I have to following issue: With Outlook 2010 - or Outlook in general - when you reply on a email with HTML format, then some formatting is used from the received email.


Often the paragraph settings are different from my template. I found a simple way to change the formatting to my standard settings:



In the open email, on the ribbon choose:
Tab "Format Text", click on "Change Styles" on the right, choose
"Style Set", select "Word 2003"



Now I would like to create a macro that does that task automatically when I select "reply", "reply all" or "forward".


Unfortunately Outlook does not have a macro recorder :(
I found something similar but there is no response at all: Outlook 2007: Reply and Forward Fails to Use Default Formatting
Or this macro here does not work: http://www.codetwo.com/admins-blog/set-email-reply-format-automatically/


What would be the macro code to do the above steps in the GUI?


Answer



You can just apply the required style set and then select Set as Default in the bottom of Change Styles menu.


Or you can do something like this:


Public WithEvents OutlookInspectors As Outlook.Inspectors
Public WithEvents OutlookInspector As Outlook.Inspector
Private Sub Application_Startup()
Set OutlookInspectors = Application.Inspectors
End Sub
Private Sub OutlookInspectors_NewInspector(ByVal Inspector As Inspector)
Set OutlookInspector = Inspector
End Sub
Private Sub OutlookInspector_Activate()
On Error Resume Next
Dim Item As MailItem
If Not OutlookInspector Is Nothing Then
Set Item = OutlookInspector.CurrentItem
If Not Item Is Nothing And Item.Size = 0 Then
OutlookInspector.WordEditor.ApplyQuickStyleSet "Word 2003"
End If
End If
Set OutlookInspector = Nothing
End Sub

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...