I found the following code that you put in ThisOutlookSession that adds to the right click menu the reply to an email that you select. Is there something to do in this code where it can add a macro that I use, or when I create a new Useform that is not related to a Module, in the ThisOutlookSesssion I add code to the ThisOutlookSession ..for example:
Public Sub runthis72()
Dim frm As New UserForm71
frm.Show
End Sub
And this code runs the Userform71. So can I add the runthis72 to the big code I will post. so it shows up in the right click menu?
Private Sub Application_ItemContextMenuDisplay( _
ByVal CommandBar As Office.CommandBar, _
ByVal Selection As Selection)
Dim objButton As CommandBarButton
Dim intButtonIndex As Integer
Dim intCounter As Integer
On Error GoTo ErrRoutine
' Ensure we have only one item selected.
If Selection.Count = 1 Then
' Ensure we have a MailItem selected.
If Selection.Item(1).Class = olMail Then
' Find the location of the Reply To All button.
For intCounter = 1 To CommandBar.Controls.Count
If CommandBar.Controls(intCounter).ID = 355 Then
intButtonIndex = intCounter
Exit For
End If
Next
' If we have a Reply To All button in the
' context menu, add a new button to support
' the ReplyToNoncopied routine.
If intButtonIndex <> 0 Then
' Create a new menu item and place it
' just after the Reply To All button
Set objButton = CommandBar.Controls.Add( _
msoControlButton, , , intButtonIndex)
' Configure the menu item.
With objButton
.Style = msoButtonIconAndCaption
.Caption = "Repl&y to Non-copied"
.Parameter = Selection.Item(1).EntryID
.FaceId = 355
' If you place this sample in a class module
' other than ThisOutlookSession, update this
' line of code to ensure that the OnAction
' property contains the correct project,
' class, and routine name.
.OnAction = "Project1.ThisOutlookSession.ReplyToNoncopied"
End With
End If
End If
End If
EndRoutine:
On Error GoTo 0
' Place clean-up code here.
Exit Sub
ErrRoutine:
MsgBox Err.Number & " - " & Err.Description, _
vbOKOnly Or vbCritical, _
"Application_ItemContextMenuDisplay"
GoTo EndRoutine
End Sub
Public Sub runthis72()
Dim frm As New UserForm71
frm.Show
End Sub
And this code runs the Userform71. So can I add the runthis72 to the big code I will post. so it shows up in the right click menu?
Private Sub Application_ItemContextMenuDisplay( _
ByVal CommandBar As Office.CommandBar, _
ByVal Selection As Selection)
Dim objButton As CommandBarButton
Dim intButtonIndex As Integer
Dim intCounter As Integer
On Error GoTo ErrRoutine
' Ensure we have only one item selected.
If Selection.Count = 1 Then
' Ensure we have a MailItem selected.
If Selection.Item(1).Class = olMail Then
' Find the location of the Reply To All button.
For intCounter = 1 To CommandBar.Controls.Count
If CommandBar.Controls(intCounter).ID = 355 Then
intButtonIndex = intCounter
Exit For
End If
Next
' If we have a Reply To All button in the
' context menu, add a new button to support
' the ReplyToNoncopied routine.
If intButtonIndex <> 0 Then
' Create a new menu item and place it
' just after the Reply To All button
Set objButton = CommandBar.Controls.Add( _
msoControlButton, , , intButtonIndex)
' Configure the menu item.
With objButton
.Style = msoButtonIconAndCaption
.Caption = "Repl&y to Non-copied"
.Parameter = Selection.Item(1).EntryID
.FaceId = 355
' If you place this sample in a class module
' other than ThisOutlookSession, update this
' line of code to ensure that the OnAction
' property contains the correct project,
' class, and routine name.
.OnAction = "Project1.ThisOutlookSession.ReplyToNoncopied"
End With
End If
End If
End If
EndRoutine:
On Error GoTo 0
' Place clean-up code here.
Exit Sub
ErrRoutine:
MsgBox Err.Number & " - " & Err.Description, _
vbOKOnly Or vbCritical, _
"Application_ItemContextMenuDisplay"
GoTo EndRoutine
End Sub