View Single Post
 
Old 04-19-2018, 04:07 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,138
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

Use the Word document inspector to edit the message directly e.g. as follows. The only major snag with this is that not all senders have their sender names formatted as you might expect. Some, for example, have the surname first.

Code:
Sub AutoAddGreetingtoReplyAll()

Dim oMail As MailItem
Dim oReply As MailItem
Dim GreetTime As String
Dim olInsp As Inspector
Dim wdDoc As Object
Dim oRng As Object

    Select Case Application.ActiveWindow.Class
        Case olInspector
            Set oMail = ActiveInspector.currentItem
        Case olExplorer
            Set oMail = ActiveExplorer.Selection.Item(1)
    End Select

    Set oReply = oMail.Reply

    With oReply
        Set olInsp = .GetInspector
        Set wdDoc = olInsp.WordEditor
        Set oRng = wdDoc.Range
        .Display
        With oRng
            .collapse 1
            .Text = "Hi " & Split(oMail.SenderName)(0) & "," & vbCr
            .Font.Name = "Century Gothic"
            .Font.Size = 11
            .collapse 0
            .Select
        End With
    End With
lbl_Exit:
    Set oMail = Nothing
    Set oReply = 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