Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-22-2016, 09:55 AM
PRA007's Avatar
PRA007 PRA007 is offline How to reset outlook style Windows 7 64bit How to reset outlook style Office 2010 32bit
Competent Performer
How to reset outlook style
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default How to reset outlook style

I have in my clipboard that I want to paste to outlook editor and after that I want to format all the text to be normal style. How to do that.



Here is the code that I got from (I forget but it was from Greg Maxy)

Code:
Sub sendcomplexemail()

Dim olapp As Object
Dim olemail As Object
Dim olInsp As Object
Dim wddoc 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 = 3
        .To = ""
        .Subject = "Movies Report"
        Set olInsp = .GetInspector
        Set wddoc = olInsp.WordEditor
        Set orng = wddoc.Range
        orng.Paste
        orng.Style = "normal"
        .Display
    End With
End Sub
I am not able to work with red part.
Reply With Quote
  #2  
Old 03-22-2016, 10:06 PM
gmayor's Avatar
gmayor gmayor is offline How to reset outlook style Windows 10 How to reset outlook style 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
Reply

Tags
microsoft outlook 2007



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to 'Reset' Outlook Contacts? markg2 Outlook 1 04-11-2015 08:26 AM
How to reset outlook style Use multiple style sets in the same Word document (depending on which section the style is in) Ricyteach Word VBA 6 03-09-2015 07:11 PM
outlook will not let me reset my password bbauer Outlook 0 08-20-2014 11:41 AM
How to reset outlook style reset numbering to 1 by paragraph Style Helix86 Word 5 08-07-2013 10:48 PM
MS Outlook Addin not responding after menu bar reset sunil_pagare Outlook 0 10-14-2009 10:34 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:22 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft