Method 'CommandBars' of Object '_inspector' Failed

S

StevenBr

My addin code works perfectly in Outlook 2003. When I run it with Outlook XP
(2002), the following line throws an error:

Set oCommandBar = m_obj.CommandBars.Add("cbTessOL", msoBarTop, False, True)

The error is "Method 'CommandBars' of Object '_inspector' Failed". Any ideas
why this might be occurring? This is a VB6 project, and the references were
changed to the Office/Outlook version for XP. Thanks!
 
K

Ken Slovak - [MVP - Outlook]

Running it compiled or in debug mode? If compiled what version of Outlook is
on the compilation machine?

What reference for Outlook are you using now?
 
S

StevenBr

I moved the entire project to the target machine, changed the references to
Office 10 from Office 11, and recompiled it.

Then I registered it and added the necessary registry entries to register it
as an addin in Outlook. The addin loads as expected. However, that line of
code fails whereas it does not with Office 11.
--
Steven Bras
Tessitura Network, Inc.


Ken Slovak - said:
Running it compiled or in debug mode? If compiled what version of Outlook is
on the compilation machine?

What reference for Outlook are you using now?
 
P

Peter Huang [MSFT]

Hi

Here I understand the m_obj should be an Inspector Object.
So please try to access to the other property of the m_obj before the code
line before is called to see if that works.
e.g. the Caption property.

I wonder if the m_obj is available at that time.

Also I suggest you recreate another Addin project with different name and
copy/paste the code there to see if helps.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

Ken Slovak - [MVP - Outlook]

Sounds OK. What event handler is running that code? I usually put my button
creation in the first Inspector.Activate event.
 
S

StevenBr

The code is basically called by the NewInspector method of the Inspectors
collection. I have written a small test project with Outlook 2002 that does
essentially the same thing in a simpler fashion and the CommandBars.add works
fine. Thanks.
--
Steven Bras
Tessitura Network, Inc.


Ken Slovak - said:
Sounds OK. What event handler is running that code? I usually put my button
creation in the first Inspector.Activate event.
 
S

StevenBr

When I attempt to access any property, even caption, or get the value of
CommandBars.Count, I get an error. With count, the error is something like
"access to a restricted memory area".
 
P

Peter Huang [MSFT]

Hi Steven,

From your reply to Ken, a test sample will work on the same machine so I
think the environment should be OK.
So have you tried my suggestion that create a new project and copy/paste
the code.
If that still did not work, I think you may try to comment out the code one
by one to see what is the cause.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

Ken Slovak - [MVP - Outlook]

In that case the code setup on the target machine is OK, it sounds like
there's something with the original project. I've personally never seen any
errors that list "_inspector" or protected memory in a VB 6 addin, that
sounds more like something a .NET addin might throw as an exception.

I'd go with Peter's suggestion of copying and pasting the code from the
original project into a new project.
 

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