View Single Post
 
Old 03-02-2018, 10:57 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

If you use the following Word macro the document will be added to the body of an Outlook e-mail message for you to add the recipients and subject just as if you had created the message in Outlook directly.

Do note that the macro requires code from http://www.rondebruin.nl/win/s1/outlook/openclose.htm to start Outlook correctly or the macro will not work. The code you need to copy to a new VBA module is that below 'Test the code'

http://www.gmayor.com/installing_macro.htm

Code:
Sub Send_As_HTML_EMail()
'Graham Mayor - http://www.gmayor.com - Last updated - 14 Jul 2017
'Requires the code from http://www.rondebruin.nl/win/s1/outlook/openclose.htm
'to either retrieve an open instance of Outlook or open Outlook if it is closed.
Dim bStarted As Boolean
Dim olApp As Object
Dim oItem As Object
Dim objdoc As Object
Dim objSel As Selection
    On Error Resume Next
    ActiveDocument.Range.Copy
    Set olApp = OutlookApp()
    Set oItem = olApp.CreateItem(0)
    With oItem
        .BodyFormat = 2
        .Display
        Set objdoc = .GetInspector.WordEditor
        Set objSel = objdoc.Windows(1).Selection
        objSel.PasteAndFormat Type:=wdFormatOriginalFormatting
        .To = ""
        .Subject = ""
    End With
lbl_Exit:
    Set oItem = Nothing
    Set olApp = Nothing
    Set objdoc = Nothing
    Set objSel = 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