View Single Post
 
Old 03-05-2020, 02:46 PM
PrincessApril PrincessApril is offline Windows 10 Office 2019
Competent Performer
 
Join Date: Nov 2019
Posts: 102
PrincessApril is on a distinguished road
Default Place Cursor in multiline HTML Body

Hi all. I am using the below code to generate an html email with the default signature in outlook. The output is great; however, the cursor does not appear until I tab or click in a field other than the body and then tab/click back into the body. I would like the cursor to appear two lines below the salutation. Any ideas on how to place the cursor, preferably without using sendkeys?

Code:
Private Sub EmailBtnUnits2020_Click()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim StrBody As String

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    StrBody = "<html><body><font size=""3"" face=""Calibri"" color=""black""><p>Hi " & ActiveSheet.Range("W4").Text & ",</p>" _
    & "</font></body></html>"

    On Error Resume Next

    With OutMail
        .Display
        .To = ActiveSheet.Range("AC4").Text
        .CC = ""
        .BCC = ""
        .Subject = "Question"
        .HTMLbody = StrBody & "<br>" & .HTMLbody
        .Display
    End With

    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub
Reply With Quote