PC Review


Reply
Thread Tools Rate Thread

Can't set CommandBarButton Tag property?

 
 
280Z28
Guest
Posts: n/a
 
      14th Jun 2006
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))


 
Reply With Quote
 
 
 
 
280Z28
Guest
Posts: n/a
 
      14th Jun 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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))
>
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Could i do this on a CommandBarButton? Ken Slovak - [MVP - Outlook] Microsoft Outlook Program Addins 0 14th Jul 2009 02:10 PM
CommandBarButton with toggle property (up & down) Jean-Pierre Bidon Microsoft Excel Programming 2 6th Nov 2007 06:31 PM
Does 2007 Office VBE Editor CommandBarButton .OnAction Property wo =?Utf-8?B?Zmdyb3Nl?= Microsoft Excel Programming 1 2nd Aug 2007 05:50 PM
.Parameter property of CommandBarButton Gregory Kip Microsoft Excel Programming 2 22nd May 2006 09:43 PM
Set CommandBarButton.Picture property (c++) Eric Microsoft Outlook Program Addins 12 24th Jan 2004 12:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:54 AM.