Applies to: Applies to: Microsoft Outlook 2010 or Outlook 2007
A user in the Microsoft Answers forum wanted to know how to use a Word macro to apply formatting to selected text in Outlook 2010.
Outlook does not (and never had) a macro recorder but you can use some VBA code that was recorded in Word, in Outlook macros provided you reference the Word object model. You'll need to set the reference in the VB Editor's Tools, References menu. You'll also need to have macro security set to low or or sign the macro with a certificate to use it.
See How to use Outlook’s VBA Editor for help using the editor, setting security levels, and signing macros.
I tested this macro in Outlook 2010; it should also work in Outlook 2007.
Format Selected Text Macro
To use, open the VBA Editor (Alt+F11) and paste the code into a module. Select a block of text while composing a message and run the macro.
Public Sub FormatSelectedText() Dim objItem As Object Dim objInsp As Outlook.Inspector ' Add reference to Word library ' in VBA Editor, Tools, References Dim objWord As Word.Application Dim objDoc As Word.Document Dim objSel As Word.Selection On Error Resume Next 'Reference the current Outlook item Set objItem = Application.ActiveInspector.currentItem If Not objItem Is Nothing Then If objItem.Class = olMail Then Set objInsp = objItem.GetInspector If objInsp.EditorType = olEditorWord Then Set objDoc = objInsp.WordEditor Set objWord = objDoc.Application Set objSel = objWord.Selection With objSel ' Formatting code goes here .Font.Color = wdColorBlue .Font.Size = 18 .Font.Bold = True .Font.Italic = True .Font.Name = "Arial" End With End If End If End If Set objItem = Nothing Set objWord = Nothing Set objSel = Nothing Set objInsp = Nothing End Sub