|
|
|
date: Wed, 14 Jun 2006 12:11:41 -0500,
group: microsoft.public.outlook.interop
back
Can't set CommandBarButton Tag property?
I'm getting an exception on the marked line (comment) in the following code
in my add-in, which seems to be correctly written. I know I'm missing
something, probably something simple. I'm trying to add a button control as
the next to last item on the menu. As you can see, I want the Click handler
to know which folder was right-clicked on to execute the command.
***** begin code *****
public void OnConnection( object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom )
{
applicationObject = (Outlook.Application)application;
addInInstance = addInInst;
applicationObject.FolderContextMenuDisplay += new
Microsoft.Office.Interop.Outlook.ApplicationEvents_11_FolderContextMenuDisplayEventHandler(
applicationObject_FolderContextMenuDisplay );
}
void applicationObject_FolderContextMenuDisplay(
Microsoft.Office.Core.CommandBar commandBar,
Microsoft.Office.Interop.Outlook.MAPIFolder folder )
{
CommandBarButton button = (CommandBarButton)commandBar.Controls.Add(
MsoControlType.msoControlButton, 1, Type.Missing,
commandBar.Controls.Count - 1, true );
// Exception occurs on next line:
button.Tag = folder.EntryID + ";" + folder.StoreID;
button.Caption = "My Command";
}
***** end code *****
The specific exception (e.Message) is:
The parameter is incorrect. (Exception from HRESULT: 0x80070057
(E_INVALIDARG))
date: Wed, 14 Jun 2006 12:11:41 -0500
author: 280Z28
Re: Can't set CommandBarButton Tag property?
Well, it seems the string was too long (that's my guess). When I set it to
just folder.EntryID, it worked. Maybe the exception message could be made
more informative.
"280Z28" wrote in message
news:O8Z8bW9jGHA.3440@TK2MSFTNGP02.phx.gbl...
> I'm getting an exception on the marked line (comment) in the following
> code in my add-in, which seems to be correctly written. I know I'm missing
> something, probably something simple. I'm trying to add a button control
> as the next to last item on the menu. As you can see, I want the Click
> handler to know which folder was right-clicked on to execute the command.
>
> ***** begin code *****
>
> public void OnConnection( object application,
> Extensibility.ext_ConnectMode connectMode, object addInInst, ref
> System.Array custom )
> {
> applicationObject = (Outlook.Application)application;
> addInInstance = addInInst;
>
> applicationObject.FolderContextMenuDisplay += new
> Microsoft.Office.Interop.Outlook.ApplicationEvents_11_FolderContextMenuDisplayEventHandler(
> applicationObject_FolderContextMenuDisplay );
> }
>
> void applicationObject_FolderContextMenuDisplay(
> Microsoft.Office.Core.CommandBar commandBar,
> Microsoft.Office.Interop.Outlook.MAPIFolder folder )
> {
> CommandBarButton button = (CommandBarButton)commandBar.Controls.Add(
> MsoControlType.msoControlButton, 1, Type.Missing,
> commandBar.Controls.Count - 1, true );
> // Exception occurs on next line:
> button.Tag = folder.EntryID + ";" + folder.StoreID;
> button.Caption = "My Command";
> }
>
> ***** end code *****
>
> The specific exception (e.Message) is:
>
> The parameter is incorrect. (Exception from HRESULT: 0x80070057
> (E_INVALIDARG))
>
>
date: Wed, 14 Jun 2006 12:59:17 -0500
author: 280Z28
|
|