PC Review


Reply
Thread Tools Rate Thread

CommandBarControl.Copy

 
 
Mikael Alhadeff
Guest
Posts: n/a
 
      27th Dec 2003
Hello,

I'm trying to add a button to both the Outlook Explorer toolbar and
the Inspectors toolbar.

As i need to get the event Click for this button, i would like to
create one CommandBarButton object and add it to the different
toolbars.

To do this, in the OnConnection Method, i create the CommandBarButton
and add it to the Explorer Standard Toolbar (if it was already on the
toolbar, i retrieve the existing one).

Then, in the Inspectors.New event handler, i try to add the existing
button using the CommandBarControl.Copy method.

The code to do this is the following :

CommandBar commandBar = Inspector.CommandBars["Standard"];
theButton.Copy(commandBar,System.Reflection.Missing.Value);
theButton.SetFocus();

When i run that code, i always get an "Invalid Parameter Exception".

If i use the following instruction :

theButton.Copy(System.Reflection.Missing.Value,System.Reflection.Missing.Value);

The button is successfully copied to the same toolbar it is already
located in (the Standard toolbar in the current explorer).

It sounds like a cast problem, but i really don't know what type of
object is the Copy method expecting for the bar parameter.

In the Outlook Object Model documentation, they say the method expect
a Variant for the CommandBar object, but as you may have noticed i'm
currently programming my addin in C#.

If someone could tell me how to cast this commandbar to avoid that
exception from being thrown, or either if there is a better way to add
the same button to both an explorer toolbar and every inspector
toolbars, it would help me a lot !

Thanks in advance,

Mikael Alhadeff

ASK sa
 
Reply With Quote
 
 
 
 
Dmitry Streblechenko
Guest
Posts: n/a
 
      28th Dec 2003
You must add a new button to each Explorer or Inspector that you want to
handle.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Mikael Alhadeff" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I'm trying to add a button to both the Outlook Explorer toolbar and
> the Inspectors toolbar.
>
> As i need to get the event Click for this button, i would like to
> create one CommandBarButton object and add it to the different
> toolbars.
>
> To do this, in the OnConnection Method, i create the CommandBarButton
> and add it to the Explorer Standard Toolbar (if it was already on the
> toolbar, i retrieve the existing one).
>
> Then, in the Inspectors.New event handler, i try to add the existing
> button using the CommandBarControl.Copy method.
>
> The code to do this is the following :
>
> CommandBar commandBar = Inspector.CommandBars["Standard"];
> theButton.Copy(commandBar,System.Reflection.Missing.Value);
> theButton.SetFocus();
>
> When i run that code, i always get an "Invalid Parameter Exception".
>
> If i use the following instruction :
>
>

theButton.Copy(System.Reflection.Missing.Value,System.Reflection.Missing.Val
ue);
>
> The button is successfully copied to the same toolbar it is already
> located in (the Standard toolbar in the current explorer).
>
> It sounds like a cast problem, but i really don't know what type of
> object is the Copy method expecting for the bar parameter.
>
> In the Outlook Object Model documentation, they say the method expect
> a Variant for the CommandBar object, but as you may have noticed i'm
> currently programming my addin in C#.
>
> If someone could tell me how to cast this commandbar to avoid that
> exception from being thrown, or either if there is a better way to add
> the same button to both an explorer toolbar and every inspector
> toolbars, it would help me a lot !
>
> Thanks in advance,
>
> Mikael Alhadeff
>
> ASK sa



 
Reply With Quote
 
Mikael Alhadeff
Guest
Posts: n/a
 
      29th Dec 2003
What is the Copy Method for then ?????

What i'm trying to do is to avoid the headache implied by
creating/destroying event handlers for "temporary buttons"...

There is no way to add the same button object to different toolbars ??

Mikael Alhadeff

ASK sa

"Dmitry Streblechenko" <(E-Mail Removed)> wrote in message news:<#(E-Mail Removed)>...
> You must add a new button to each Explorer or Inspector that you want to
> handle.
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>
>
> "Mikael Alhadeff" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hello,
> >
> > I'm trying to add a button to both the Outlook Explorer toolbar and
> > the Inspectors toolbar.
> >
> > As i need to get the event Click for this button, i would like to
> > create one CommandBarButton object and add it to the different
> > toolbars.
> >
> > To do this, in the OnConnection Method, i create the CommandBarButton
> > and add it to the Explorer Standard Toolbar (if it was already on the
> > toolbar, i retrieve the existing one).
> >
> > Then, in the Inspectors.New event handler, i try to add the existing
> > button using the CommandBarControl.Copy method.
> >
> > The code to do this is the following :
> >
> > CommandBar commandBar = Inspector.CommandBars["Standard"];
> > theButton.Copy(commandBar,System.Reflection.Missing.Value);
> > theButton.SetFocus();
> >
> > When i run that code, i always get an "Invalid Parameter Exception".
> >
> > If i use the following instruction :
> >
> >

> theButton.Copy(System.Reflection.Missing.Value,System.Reflection.Missing.Val
> ue);
> >
> > The button is successfully copied to the same toolbar it is already
> > located in (the Standard toolbar in the current explorer).
> >
> > It sounds like a cast problem, but i really don't know what type of
> > object is the Copy method expecting for the bar parameter.
> >
> > In the Outlook Object Model documentation, they say the method expect
> > a Variant for the CommandBar object, but as you may have noticed i'm
> > currently programming my addin in C#.
> >
> > If someone could tell me how to cast this commandbar to avoid that
> > exception from being thrown, or either if there is a better way to add
> > the same button to both an explorer toolbar and every inspector
> > toolbars, it would help me a lot !
> >
> > Thanks in advance,
> >
> > Mikael Alhadeff
> >
> > ASK sa

 
Reply With Quote
 
Dmitry Streblechenko
Guest
Posts: n/a
 
      29th Dec 2003
I don't see how you can simplify your code by using a single button - you
need to add a button at least once, so you have to have code that creates a
button. Whether the code runs once for the first button only or for each new
inspector/explorer does not simplify your code. You end up having more code
as now you have to figure out when you need to create a button and when to
copy an existing one.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Mikael Alhadeff" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> What is the Copy Method for then ?????
>
> What i'm trying to do is to avoid the headache implied by
> creating/destroying event handlers for "temporary buttons"...
>
> There is no way to add the same button object to different toolbars ??
>
> Mikael Alhadeff
>
> ASK sa
>
> "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message

news:<#(E-Mail Removed)>...
> > You must add a new button to each Explorer or Inspector that you want to
> > handle.
> >
> > Dmitry Streblechenko (MVP)
> > http://www.dimastr.com/
> > OutlookSpy - Outlook, CDO
> > and MAPI Developer Tool
> >
> >
> > "Mikael Alhadeff" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > Hello,
> > >
> > > I'm trying to add a button to both the Outlook Explorer toolbar and
> > > the Inspectors toolbar.
> > >
> > > As i need to get the event Click for this button, i would like to
> > > create one CommandBarButton object and add it to the different
> > > toolbars.
> > >
> > > To do this, in the OnConnection Method, i create the CommandBarButton
> > > and add it to the Explorer Standard Toolbar (if it was already on the
> > > toolbar, i retrieve the existing one).
> > >
> > > Then, in the Inspectors.New event handler, i try to add the existing
> > > button using the CommandBarControl.Copy method.
> > >
> > > The code to do this is the following :
> > >
> > > CommandBar commandBar = Inspector.CommandBars["Standard"];
> > > theButton.Copy(commandBar,System.Reflection.Missing.Value);
> > > theButton.SetFocus();
> > >
> > > When i run that code, i always get an "Invalid Parameter Exception".
> > >
> > > If i use the following instruction :
> > >
> > >

> >

theButton.Copy(System.Reflection.Missing.Value,System.Reflection.Missing.Val
> > ue);
> > >
> > > The button is successfully copied to the same toolbar it is already
> > > located in (the Standard toolbar in the current explorer).
> > >
> > > It sounds like a cast problem, but i really don't know what type of
> > > object is the Copy method expecting for the bar parameter.
> > >
> > > In the Outlook Object Model documentation, they say the method expect
> > > a Variant for the CommandBar object, but as you may have noticed i'm
> > > currently programming my addin in C#.
> > >
> > > If someone could tell me how to cast this commandbar to avoid that
> > > exception from being thrown, or either if there is a better way to add
> > > the same button to both an explorer toolbar and every inspector
> > > toolbars, it would help me a lot !
> > >
> > > Thanks in advance,
> > >
> > > Mikael Alhadeff
> > >
> > > ASK sa



 
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
CommandBarControl ComboBox Renjith Microsoft Outlook 0 10th Jul 2006 11:47 AM
CommandBarControl Dale@community.nospam Microsoft Access Form Coding 3 4th Jan 2005 08:29 PM
Code to enable "copy" in commandbarcontrol Jonsson Microsoft Excel Misc 2 6th Sep 2004 04:17 PM
CommandBarControl works in one WB but not another Dkline Microsoft Excel Programming 1 30th Mar 2004 03:52 PM
CommandBarControl class John A Grandy Microsoft Excel Programming 2 19th Jul 2003 07:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:04 PM.