Error 91 adding toolbar button in OL03 after KB924085

J

Jefferson

COM Add-ins developed in Office XP Developer Edition adds two menu items and
a toolbar button when a new inspector is launched. After installing the
security update, the two menu items are added but RT error 91 "Object
variable or With block variable not set" appears before the toolbar button is
added. Not clear whether the error occurs on setting the action for the
second menu item or adding the toolbar button.

Uninstalling KB924085 resolves the issue.

Any insight on this?
 
K

Ken Slovak - [MVP - Outlook]

What type of Inspector, mail or contact or what?

What's your code for creating the buttons and accessing them and when are
you instantiating them?

If these are mail Inspectors is WordMail involved?
 
K

Ken Slovak - [MVP - Outlook]

Never use NewInspector to do much of anything with an Inspector or its
CurrentItem. Wait for the first Activate event on the Inspector. That's
especially true if you are handling WordMail. In fact, in NewInspector in
Outlook 2007 you can't even get a valid value for Inspector.IsWordMail.

In NewInspector you get what's called a weak object reference to the
Inspector. Many of its properties aren't valid until Activate fires.
 
K

Ken Slovak - [MVP - Outlook]

Well, I'm not sure what KB924085 would have to do with that problem, it
supposedly only does things with .OSS files (saving and loading) from
Advanced Searches. I'd maybe open a support incident with PSS and see if
it's a reported bug or if they know of a workaround.

You have to use NewInspector to be able to set up your Inspector event
handler. I was suggesting that you don't use it for much more than checking
Inspector.CurrentItem and setting up your Inspector handler. All the heavy
lifting should be done in Inspector.Activate.
 
J

Johannes

I have actually run into a problem with KB924085 myself right now. In
the Inspector.Close() event I used to rely on the Inspector->Item being
0 if the inspector is _really_ closing, and it not being 0 if the close
has been canceled. This doesn't work anymore with this security update.
The item is never 0, close canceled or not.
 
J

Johannes

Correction, Inspector.Close() now only fires if the item really closes,
not if the close is canceled. This is the same as in Outlook 2007.
 
K

Ken Slovak - [MVP - Outlook]

On re-reading this thread let me correct one thing I said, and make sure I'm
clear on something you said.

In NewInspector you can't get a valid Inspector.WordEditor object. I had
said that .IsWordMail was invalid.

You were duplicating the creation of the CommandBars object in both
NewInspector and Inspector.Activate? I can see the weak object reference not
having a valid Inspector.CommandBars collection in NewInspector, especially
with WordMail. I can also see the patch changing the behavior of
Inspector.CommandBars. It was always a better practice to use .Activate for
creating UI than using NewInspector, even if it worked in NewInspector.
 
J

Jefferson

Ken Slovak - said:
You were duplicating the creation of the CommandBars object in both
NewInspector and Inspector.Activate? I can see the weak object reference not
having a valid Inspector.CommandBars collection in NewInspector, especially
with WordMail. I can also see the patch changing the behavior of
Inspector.CommandBars. It was always a better practice to use .Activate for
creating UI than using NewInspector, even if it worked in NewInspector.

Word wasn't involved, but I was able to resolve the problem. I had some
references to ActiveInspector.CommandBars in the _Activate procedure.
Removing those eliminated the error. Not sure why this behaves differently
after KB924085, but all is well now.
 

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