View Single Post
 
Old 02-13-2019, 09:51 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 are using late binding to Outlook you need to change two lines
Code:
Set EmailItem = OL.CreateItem(0)
and
Code:
.Importance = 1    'Or olImportanceHigh (2) Or olImportanceLow (0)
Word doesn't recognize Outlook specific commands and you must use the numeric equivalents.
If you want to keep the signature or edit the message body directly, you will need to use the following - note the comment at the top
Code:
Private Sub CommandButton1_Click()
'Use the code from http://www.rondebruin.nl/win/s1/outlook/openclose.htm
'To open Outlook correctly or this won't work
Dim OL As Object
Dim EmailItem As Object
Dim olApp As Object
Dim olInsp As Object
Dim Doc As Document
Dim wdDoc As Object
Dim oRng As Object

    Application.ScreenUpdating = False
    Set OL = OutlookApp()
    Set EmailItem = OL.CreateItem(0)
    Set Doc = ActiveDocument

    With EmailItem
        .Subject = "Hello"
        .to = "acas-media@media.co.uk"
        .Importance = 1    'Or olImportanceHigh (2) Or olImportanceLow (0)
        Set olInsp = .GetInspector
        Set wdDoc = olInsp.WordEditor
        Set oRng = wdDoc.Range
        oRng.Collapse 1
        oRng.Text = "Insert message here or just send"
        .Attachments.Add Doc.FullName
        .Display
    End With

    Application.ScreenUpdating = True

    Set Doc = Nothing
    Set OL = Nothing
    Set EmailItem = Nothing
    Set wdDoc = Nothing
    Set oRng = Nothing
    Set olInsp = Nothing
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