Debug com addin


Hans Börjesson


I have a VB6 Outlook Com addin and I have problems when I try to debug my
code. When starting Outlook my code to add/delete a commandbar always raises
an exception that does not make it possible to debug any more. If I don't
debug everything works fine (commanbars are added/deleted OK).

For Each oCommandBar In m_objExpl.CommandBars
If oCommandBar.Name = "VendimoToolbar" Then
For i = 1 To oCommandBar.Controls.Count
oCommandBar.Controls.Item(i).Delete False
Next i
End If
Next oCommandBar

I get error 13 Type missmatch (oCommandBar is declared As

My VB project is set to binary compability and it is pointing att the right
dll file.

Plattform: W2000 proffesional, Outlook 2000 SR1.


Ken Slovak - [MVP - Outlook]

You should always delete items from a collection using a count down
loop so the loop counter doesn't get confused:
For i = m_objExpl.CommandBars.Count To 1 Step -1
Set oBar = m_objExpl.CommandBars.Item(i)
Next i

You also should use a unique Tag property if the CommandBar is user
created instead of using a name, which might be duplicated. For
example the Actions menu is duplicated in the "Menu Bar" CommandBar

Hans Börjesson

Hi Ken!

I have tested with this earlier (and I tried it now once again) and I get
exception anyway "Method 'item' of _commandbars failed. If I debug the
m_objExpl.CommandBars.Count it seems to show the right number of elements.
If I did not call my function to delete my toolbar (which I actually think I
don't have to call since I use the temporary=true when I create the toolbar)
it fails when I try do add my commandbar with error Interface not

There must be something corrupt with my registry but I don't understan why
it works when I run the dll and not when I run via VB.

Set oCommandBar = m_objExpl.CommandBars.Add("VendimoToolbar", , , True)
oCommandBar.Visible = True
oCommandBar.Enabled = True
oCommandBar.Position = msoBarTop

Set oCmdExplorerBtn = oCommandBar.Controls.Add(msoControlButton, , , ,
oCmdExplorerBtn.Caption = g_xml.WriteTextValue("msg_028")
oCmdExplorerBtn.Enabled = True
oCmdExplorerBtn.Visible = True
oCmdExplorerBtn.Tag = GetNewGuid
m_btoolbarsAdded = True


Ken Slovak - [MVP - Outlook]

Early versions of Outlook 2000 do need you to explicitly delete the
commandbar even if declared as temporary. Otherwise you sometimes end
up with a lot of those temporary buttons.

I'm really not sure why the code is working in run mode and not in
debug mode. I haven't seen that and other than John's similar problem
I haven't heard of it before. Sorry I can't be of more help in this.
The only other thing I can think of is to install VB on another
machine and see if it displays the same debug mode problems.

Hans Börjesson

Thanks Ken!

I received a new version of redemption.dll today and my problem original
problem disappeared with the new dll so I do no longer have to debug my code
anymore (even if It would be nice to have it work though).

I'm still interested to here if anyone have a solution for my problem to
debug my com addin.


John Covert

Hans & Company:

I've been working sixteen hour days for the past four days trying to get
this remedied and my diet from dinner to sleep has been coffee and nicotine
so kindly do not accept this as gospel, but here goes:

I believe I have this issue (debugging in VB) resolved.

What appears to have fixed it is downloading and installing Office 2000
Service Release 1a (SR-1a).

In my case, I could watch objOutlookApplication and "browse" the
ActiveExplorer.CommandBars property, but if I tried to watch
objOutlookApplication.ActiveExplorer.CommandBars, I'd get Interface not
Registered or Method 'item' of _commandbars failed....

This indicated that it was Office that was somehow corrupted, since in the
former case CommandBars was a member of an Outlook Object/Class whereas
objOutlookApplication.ActiveExplorer.CommandBars is an Office Object/Class.

I'm just a Business School graduate who decided to code one day so I know
not the internals but I figured corruption of Office DLLs ==or=== corruption
of Office 2000's registry entries was the culprit.

At any rate, installing SR-1a appears to have fixed it.

You can find it here:

Of course I cannot warranty this solution and I have not fully tested here
but Hans from your email I know you are "in a coma" with respect to getting
this done so i toss this "out there".

You will need your Office 2000 CDs.

Best of luck,


Hans Börjesson


Since I already had SR1 installed I did a repair on this and it looks like
it is working now so thanks Dave for the tip!


Hans Börjesson

Sorry thanks John (not Dave)!

Have been working too many hours....


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