Thread: [Solved] How to reset outlook style
View Single Post
 
Old 03-22-2016, 10:06 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The style names are case sensitive, so the correct code would be as follows. Note that this code sequence is normally intended to be run from applications other than Outlook (though it will run from Outlook VBA). Set the range to the start of the document range if you wish to include the signature in your message (as shown). You must always include .Display, even if the next line is .Send.

Use html body format (2).

Code:
Option Explicit

Sub sendcomplexemail()

Dim olApp As Object
Dim olEmail As Object
Dim olInsp As Object
Dim wdDoc As Object
Dim oRng As Object

    On Error Resume Next
    Set olApp = GetObject(, "Outlook.Application")
    If Err <> 0 Then Set olApp = CreateObject("Outlook.Application")
    On Error GoTo 0
    Set olEmail = olApp.CreateItem(0)
    With olEmail
        .BodyFormat = 2
        .To = ""
        .Subject = "Movies Report"
        Set olInsp = .GetInspector
        Set wdDoc = olInsp.WordEditor
        Set oRng = wdDoc.Range(0, 0)
        oRng.Paste
        oRng.Style = "Normal"
        .Display
    End With
lbl_Exit:
    Set olApp = Nothing
    Set olEmail = Nothing
    Set olInsp = Nothing
    Set wdDoc = Nothing
    Set oRng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote