Outlook add-in causing Word 2003 toolbar problems

D

Dan Teven

My Outlook add-in creates a temporary toolbar in every inspector
window. It seems to work fine in Outlook 2002, whether Outlook or Word
is selected as the e-mail editor. It also works fine in Outlook 2003
when Outlook is the e-mail editor.

However, when Outlook 2003 is set to use WordMail, I have serious
problems. The symptoms seem to differ from computer to computer, but
there are two common ones:

1. Sometimes, my toolbar appears when I open the first WordMail
window, but it's gone when I open subsequent windows -- whether through
New, Reply, or Forward. (It is still listed, unchecked, on the menu
when I right-click in the toolbar area, and it works if I manually
re-check it, but it disappears again on the next window.)

2. Sometimes, the toolbar appears consistently in the WordMail
windows, but also shows up in regular Word documents (where it is not
wanted).

Judging from the tens of thousands of hits I get when I google for
similar problems, I'm going to need another solution. I tried using a
permanent toolbar; I ended up with symptom #2 in spades. I tried
explicitly deleting the temporary one in the InspectorEvents.Close
handler, thinking I could get Word to recreate it each time; it didn't
seem to make a difference. I am about ready to attempt a Word
auto-startup macro to create the toolbar, but I know nothing about Word
macros and I don't know if I can deploy one without triggering a
security warning.

What I'm trying to accomplish seems really straightforward. Has anyone
found a completely satisfactory implementation?
 
K

Ken Slovak - [MVP - Outlook]

If WordMail is being used (test for that in your startup for your Inspector
class wrapper) then in the first Inspector.Activate event instantiate a Word
application object declared WithEvents so you can handle Word events.

Handle the WindowActivate event from Word. It will look something like this:

Private Sub oWord_WindowActivate(ByVal Doc As Word.Document, ByVal Wn As
Word.Window)

In that event handler check for Wn.EnvelopeVisible = True. If that is true
then the new window is a WordMail window. Otherwise it's a Word document
window. Check for the toolbar being being there if True and if so delete it.
You will also have to use Doc.AttachedTemplate.Saved = True where Doc is the
Word document object (either WordMail or a doc) to prevent the user from
being prompted to save Normal.dot if their settings ask for prompting.
 
D

Dan Teven

Thanks Ken!

I had already figured out some of this. If the inspector IsWordMail, I
get the Word.Document object. (I have Redemption so I just get it from
the SafeInspector.) From that I can get the Word.Application object,
and from that I can get the customization context, which I'm now
setting to the active document (not the normal template).

The customization context was the missing piece for solving problem #2
above. The Outlook doc says nothing about it, of course, and implies
that the temporary toolbars work the same way across all of Office.
Once I dug into the Word object model doc, and read some other posts
(for example, http://www.typepad.com/t/trackback/2819117) I realized
that I needed to use the customization context instead of relying on
the broken temporary-toolbar implementation.

Just awful documentation from Microsoft on this one...judging from the
number of other people who have fallen into the same mire!

I'm not sure what the EnvelopeVisible property buys me. As long as I
only create my toolbar when I get the NewInspector event, then I should
only attempt to create it within e-mail documents. And if I use the
customization context properly then it shouldn't "bleed through" to
other documents. Or am I missing something?

As for problem #1 above, it seems to be timing-related. I found on my
own that I couldn't get the Word.Document object at NewInspector time,
but that I can get it if I wait for the first Inspector.Activate event.
I also found that I had to wait an indeterminate amount of time after
that before trying to enable/show my toolbar. You suggest registering
for a Word activation event and waiting for that, which is really
messy, but if you're sure it's technically correct then I'll do it.

Thanks again,

Dan
 
K

Ken Slovak - [MVP - Outlook]

Actually, it was a Word window activation event which I suggested. It
depends on how you set up customization context, and depends on the versions
of Word and Outlook you have to support. I use both methods at different
times, the one I suggested and the one you came up with.

Generally if you wait until the first Inspector.Activate then you can get
the Word objects with all their properties. If you don't wait for that some
things aren't available. I've found that using Word.WindowActivate is good
for things I do, it's not the only way or the best way.

It's not an Outlook thing that the temporary property doesn't work in
WordMail, it's more that Word doesn't respect that property.

EnvelopeVisible is useful to check if you are in a WordMail window when you
need to know that, and if customization context is in a template rather than
the doc it's needed to know when to create your buttons and when not to
create them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top