尝试设置宏以将现有Outlook便笺文件附加到收件箱中的现有Outlook邮件。我已经让它工作了99%,但是,当然有1%是让我着迷的。我找到的最简单的方法是使用SendKeys(简单,b / c,按行业我不是编码器),但是最终的“ Enter”将不会执行。没有引发任何错误,它就像完成了一样。请帮忙吗?
我要使代码做什么:
在下面的示例中,列表中出现的第一个音符(标题为“ _MyNotes”)是我想要的音符,因此我只需要a)按下“ enter”或b)按下“ Tab”即可转移焦点,然后点击“输入”以将其插入到消息中。当我手动执行时,两种方法都可以工作。当我使用代码时,两者都不起作用。 TIA
Sub plusNote()
Dim myItem As Outlook.MailItem
Dim objInsp As Outlook.Inspector
Dim objActionsMenu As Office.CommandBarControl
Dim olNewMailItem As Outlook.MailItem
' get valid ref to current item
On Error Resume Next
Select Case TypeName(Application.ActiveWindow)
Case "Explorer"
Set myItem = ActiveExplorer.Selection.Item(1)
myItem.Display
Case "Inspector"
Set myItem = ActiveInspector.CurrentItem
Case Else
End Select
On Error GoTo 0
If myItem Is Nothing Then
MsgBox "Could not use current item. Please select or open a single email.", _
vbInformation
GoTo exitproc
End If
SendKeys "{ENTER}", True
SendKeys "%HAE", True
' This next line is what causes the problem - I can see that Notes is highlighted
' so it works through %NAMN, but then it doesn't execute the ENTER.
SendKeys "%NAMN{ENTER}"
SendKeys "^S"
exitproc:
Set myItem = Nothing
Set objInsp = Nothing
Set objActionsMenu = Nothing
Set olNewMailItem = Nothing
End Sub