M
Mikael Alhadeff
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
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