Convert a Word macro to an Outlook macro

Alexander Howard 0 Reputation points
2025-08-04T06:14:09.58+00:00

Outlook VBA: I want to format email text in Outlook as easily as in Word. I have a one-lin Word macro that I can run with a single click, and would like to use the same when typing emails in Outlook:

Selection.Style = ActiveDocument.Styles("Text")

(I have other macros for other defined paragraph styles,.)

Is there a code that wil do the same in Outlook?

Microsoft 365 and Office | Development | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. TiNo-T 4,215 Reputation points Microsoft External Staff Moderator
    2025-08-04T07:48:48.11+00:00

    Dear @Alexander Howard,

    Thank you so much for contacting Microsoft Q&A Forum. 

    Based on your description, it's absolutely possible to apply Word-style formatting to Outlook email text using VBA, though it requires a bit more setup than in Word. However, you cannot run VBA macros in Outlook Web App (OWA) or the New Outlook interface that mimics the web version. This is because: 

    • OWA is browser-based and does not support the COM (Component Object Model) architecture that VBA relies on. 
    • New Outlook, which is essentially a web-based client wrapped in a desktop shell, also lacks support for VBA and other developer tools like PST import/export. 
    • You can't access the Visual Basic Editor or run macros using Alt + F11 in OWA or New Outlook. 

    References: 

    User's image

    So, only the classic Outlook desktop application (also known as Outlook for Windows) supports running VBA macros. The macro is designed to apply a specific Word style (like "Text") to the selected text in the body of an email you're composing in Outlook. This is useful if you want consistent formatting across emails using predefined styles, just like you do in Word. 

    You can see in this article to know the setup for VBA macro in classic Outlook: How to automate tasks in Outlook using macros – Microsoft 365 

    Kindly note: make sure macro security is set to allow macros: Go to File > Options > Trust Center > Trust Center Settings > Macro Settings. 

    Besides that, if you want to use Classic Outlook, download it to use on your computer via: Install or reinstall classic Outlook on a Windows PC - Microsoft Support. And if you have installed the Classic Outlook, you can click Help in the menu bar and select "Go to Classic Version". 

    User's image

    Also, I have a sample suggestion for VBA code that you can check if it can help after finishing the setup (you can consult other online codes): 

    Public Sub ApplyTextStyle()

        Dim objItem As Object

        Dim objInsp As Outlook.Inspector

        Dim objWord As Word.Application

        Dim objDoc As Word.Document

        Dim objSel As Word.Selection

        On Error Resume Next

        ' Get the current email item

        Set objItem = Application.ActiveInspector.CurrentItem

        If Not objItem Is Nothing Then

            If objItem.Class = olMail Then

                Set objInsp = objItem.GetInspector

                ' Ensure the editor is Word

                If objInsp.EditorType = olEditorWord Then

                    Set objDoc = objInsp.WordEditor

                    Set objWord = objDoc.Application

                    Set objSel = objWord.Selection

                    ' Apply the style named "Text"

                    objSel.Style = objDoc.Styles("Text")

                End If

            End If

        End If

        ' Clean up

        Set objItem = Nothing

        Set objInsp = Nothing

        Set objWord = Nothing

        Set objDoc = Nothing

        Set objSel = Nothing

    End Sub

    I hope this information can help you to understand about this feature and please correct me if I misunderstand your concern. 

    Wish you a pleasant day! 


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. 

    User's image


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.