![]() |
|
#1
|
||||
|
||||
![]()
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 |
#2
|
||||
|
||||
![]()
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 |
![]() |
Tags |
microsoft outlook 2007 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to 'Reset' Outlook Contacts? | markg2 | Outlook | 1 | 04-11-2015 08:26 AM |
![]() |
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 |
![]() |
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 |