RibbonDropDown selecteditem depending on ItemProperty.

Status
Not open for further replies.
C

chris

Hi,

I have a RibbonDropDown with 10 values. This RibbonDropDown is placed inside

a Ribbon (designer). This Ribbon is set to display on Mail.Read in the

Message tab. When I open an email I need to get the value of an ItemProperty

of the current Inspector (the MailItem I am opening) and set a default value

in the RibbonDropDown. Setting the default value is not the problem. What I

am having trouble with is placing the code in the right place. I tried to do

it on the Activate event for the current Inspector but that seems to fire

only when I set the current window to the active window, not when I open the

email. I also tried when a new inspector is created, but that doesn't work

either.

How can I achieve this?

Thanks for the help.
 
The first Activate() event is the correct place for your code. Before that

the item properties and Inspector properties aren't fully filled in (you

have weak object references). When you open an item it will always fire an

Activate() event, use that.

"chris" <chris> wrote in message

news:2D2C64CE-E7E0-431A-9B1D-4F5CBFD17BAF@microsoft.com...
> Hi,

> I have a RibbonDropDown with 10 values. This RibbonDropDown is placed
> inside
> a Ribbon (designer). This Ribbon is set to display on Mail.Read in the
> Message tab. When I open an email I need to get the value of an
> ItemProperty
> of the current Inspector (the MailItem I am opening) and set a default
> value
> in the RibbonDropDown. Setting the default value is not the problem. What
> I
> am having trouble with is placing the code in the right place. I tried to
> do
> it on the Activate event for the current Inspector but that seems to fire
> only when I set the current window to the active window, not when I open
> the
> email. I also tried when a new inspector is created, but that doesn't work
> either.

> How can I achieve this?

> Thanks for the help.

>
 
Thanks for the reply!

I have tried putting the code in the Activate event handler, but I can see

the item selected only on the rest of the of the times when the Activate is

executed, not on the first one. Am I not picking up the Current Inspector

correctly?

void Inspector_Activate()

{

Outlook.MailItem email =

(Outlook.MailItem)Globals.ThisAddIn.ActiveInspector().CurrentItem;

Outlook.ItemProperty item =

(Outlook.ItemProperty)email.ItemProperties["myId"];

if(item != null)

{

// code here

}

}

Thanks!
wrote:


> The first Activate() event is the correct place for your code. Before that
> the item properties and Inspector properties aren't fully filled in (you
> have weak object references). When you open an item it will always fire an
> Activate() event, use that.

> >

>

> "chris" <chris> wrote in message
> news:2D2C64CE-E7E0-431A-9B1D-4F5CBFD17BAF@microsoft.com...
> > Hi,
> > I have a RibbonDropDown with 10 values. This RibbonDropDown is placed
> > inside
> > a Ribbon (designer). This Ribbon is set to display on Mail.Read in the
> > Message tab. When I open an email I need to get the value of an
> > ItemProperty
> > of the current Inspector (the MailItem I am opening) and set a default
> > value
> > in the RibbonDropDown. Setting the default value is not the problem. What
> > I
> > am having trouble with is placing the code in the right place. I tried to
> > do
> > it on the Activate event for the current Inspector but that seems to fire
> > only when I set the current window to the active window, not when I open
> > the
> > email. I also tried when a new inspector is created, but that doesn't work
> > either.
> > How can I achieve this?
> > Thanks for the help.
> >


> .
>
 
You should be handling Inspectors.NewInspector() and instantiating an

Activate() handler for that new Inspector. Why are you then getting

ActiveInspector() which most likely will not point where you want until

after the Activate() event fires?

"chris" <chris> wrote in message

news:0B5691B1-3E32-4F75-B9E0-6BCAF91C08DB@microsoft.com...
> Thanks for the reply!

> I have tried putting the code in the Activate event handler, but I can see
> the item selected only on the rest of the of the times when the Activate
> is
> executed, not on the first one. Am I not picking up the Current Inspector
> correctly?

> void Inspector_Activate()
> {
> Outlook.MailItem email =
> (Outlook.MailItem)Globals.ThisAddIn.ActiveInspector().CurrentItem;
> Outlook.ItemProperty item =
> (Outlook.ItemProperty)email.ItemProperties["myId"];
> if(item != null)
> {
> // code here
> }
> }

> Thanks!
 
Status
Not open for further replies.
Back
Top