|
请问怎么在outlook中用VBA添加自定义右键菜单?
下面的代码是网上找的,(直接复制到ThisOutlookSession),但是没用,不知道问题在哪里,请指点。
Private Sub Application_ItemContextMenuDisplay(ByVal CommandBar As Office.CommandBar, ByVal Selection As Selection)
Dim btnResend As CommandBarButton, btnResendNow As CommandBarButton
On Error Resume Next
If Selection.Count = 1 Then
If Selection.Item(1).Class = olMail Then
Set btnResend = CommandBar.Controls.Add(msoControlButton)
With btnResend
.BeginGroup = True
.Caption = "重新发送..."
.OnAction = "Project1.ThisOutlookSession.ReSendSelectedItem"
End With
End If
End If
End Sub
Private Sub ReSendSelectedItem()
On Error Resume Next
Dim oOldItem As MailItem, oNewItem As MailItem
Set oOldItem = ActiveExplorer.Selection.Item(1)
oOldItem.Display
ActiveInspector.CommandBars.FindControl(, 3165).Execute
oOldItem.Close olDiscard
End Sub
|
|