View Single Post
  #2  
Old January 23rd 08, 02:41 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Inspector Wrapper

No need to post this 3 times.

WordMail is completely different than an Outlook editor Inspector. In
WordMail for Outlook 2003 and earlier the UI you add gets placed wherever
the CustomizationContext points (Word.Application.CustomizationContext).

That has a number of implications. First, if CustomizationContext.Saved is
False then when Outlook is closed the user will get prompted to save
Normal.dot (if that's where CustomizationContext points) if they have the
setting to be prompted to save Normal.dot. If they don't have that setting
then the UI will just be saved and reappear the next time Word is opened.

Second, any UI you add will appear always unless explicitly removed. Word
doesn't honor the Temporary = True setting you might apply when you create
the UI. So you must explicitly delete the UI you created when the
item/Inspector is closing.

Finally, since Word will show all UI instances not only when WordMail items
are open but also in Word documents (try opening a doc when Inspectors are
open to see that) you need code to see if a Word window is a WordMail window
and which WordMail window if more than one is open.

That final piece is the key. Use a Word event handler to handle
Window_Activate. In that event handler check that window for
wn.EnvelopeVisible = True. If True it's a WordMail window. If False it's a
doc window. In that case you iterate all the Word CommandBars and see which
are yours and which are not. Disable yours and set Visible = False for each
one. If it is WordMail use code to match your unique Tag (which should
include the wrapper class Key value) with the current Inspector. That UI
gets enabled and made visible, any other UI gets disabled and made
invisible.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"goran" wrote in message
...
Hi,
I used MicroEye example and Ken's InspectorWrapper to create Outlook 2003
add-in. This add-in adds a new CommandBar with a dropdown and command
button
to the outlook toolbar. Everything is fine if I open multiple emails from
Inbox. I see exactly one
commandbar with dropdown and a button in it. But when I open multiple new
mail inspectors, it adds 2 command bars for second inspector, 3 for third
etc.
It looks like it carries command bars from previously opened inspectors. I
use colInsp_NewInspector method in OutAdddin class to call AddInsp method
in
the bas module to add each inspector to the collection.
I use mail_open method to call CreateMenus where I assign unique tag to
each
commandbar, dropdown and a button. When I delete one of those commandbars,
it
disappears from all open inspectors. I should mention that Email editor is
Word editor. Any ideas?
Thanks in advance,

Goran


Ads