Outlook MailItem 中的焦点正文

Focusing Body in Outlook MailItem

填写 "To" 后,我向我的 MailBody 写了一个自动称呼。在输入此称呼后,我还进行了文本选择。

    m_MailItem.Body = newMailBody
    m_SalutationEntered = True

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

到目前为止一切正常。但是在处理这个之后,我没有 "real" 焦点,这意味着当我按任意键时,没有任何内容输入到正文中。我可以看到光标,但它没有闪烁。希望你明白我的意思。

您需要找到编辑器的 window 句柄(FindWindow 等),然后使用 SetActiveWindow / SetFocus / ShowCaret Windows API 函数聚焦编辑器并显示插入符号。

如果使用Redemption is an option (I am its author), it exposes SafeInspector.FocusEditor方法:

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