etalon11
etalon11

Reputation: 984

Focusing Body in Outlook MailItem

After filling the "To" I write an automatic salutation to my MailBody. Also I make a Text-Selection after this typed salutation.

    m_MailItem.Body = newMailBody
    m_SalutationEntered = True

    With m_WordEditor.Application.Selection
        .Start = newMailBody.IndexOf(vbCrLf & vbCrLf) + 1
    End With

This is working fine so far. But after handling this, I have no "real" focus, which means when I press any key, nothing is typed to the body. I can see the cursor but it is not blinking. Hope you understand what I mean.

Upvotes: 0

Views: 676

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66255

You will need to find the window handle of the editor (FindWindow etc.), then use SetActiveWindow / SetFocus / ShowCaret Windows API functions to focus the editor and show the caret.

If using Redemption is an option (I am its author), it exposes SafeInspector.FocusEditor method:

 set sInspector = CreateObject("Redemption.SafeInspector")
 sInspector.Item = Application.ActiveInspector
 sInspector.FocusEditor

Upvotes: 1

Related Questions