Where did you put that code? Is it in the Outlook VBA project? You need to
make sure that you have project references set to Outlook and to Office, and
that the Outlook reference is ahead of any other application that exposes a
Selection object or collection.
You can also just fully qualify the code by changing Selection to
Outlook.Selection and changing msoControlButton to
Office.MsoControl.msoControlButton.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm
"pavanmuppidi" wrote in message
news

Private Sub Application_ItemContextMenuDisplay(ByVal CommandBar As
Office.CommandBar, ByVal Selection As Selection)
Static intCounter As Integer
On Error GoTo ErrRoutine
' Increment or reset the counter
If intCounter 1 Or intCounter 100 Then
intCounter = 1
Else
intCounter = intCounter + 1
End If
' Add the menu.
Dim objMenu As Object
objMenu = CommandBar.Controls.Add(msoControlButton)
objMenu.Caption = "Displayed " & intCounter & " times"
objMenu.Enabled = False
objMenu.BeginGroup = True
EndRoutine:
On Error GoTo 0
Exit Sub
ErrRoutine:
MsgBox(Err.Number & " - " & Err.Description, _
vbOKOnly Or vbCritical, _
"Application_ItemContextMenuDisplay")
GoTo EndRoutine
End Sub
i'm getting error at
1) "Selection" (Type Selection is not defined)
2) "msoControlButton" (msoControlButton name not defined.)
i would like to do this in C#.Net. (or VB.Net)
could u suggest me to resolve this.
Regards,
Muppidi.
--
pavanmuppidi