custom toolbars

MajorTom
10-12-2004, 02:18 PM
Split from this rather old thread (http://www.xtremevbtalk.com/showthread.php?t=141357).
Please don't re-open threads that have been inactive for more than a couple of weeks - start a new thread instead.

First of all, thanks for providing that code. It's just what I needed and works great. I'm having trouble, however when turning Option Strict On.

The problem occurs on the following line:
cbTarget = cbcParant.Controls.add(Type:=MsoControlType.msoControlButton)

The error is "Option Strict On disallows late binding". I was able to appease the compiler by changing the line to:
cbTarget = CType(cbcParant.Parent.Controls.Add(Type:=MsoControlType.msoControlBut ton), CommandBarButton)

Unfortunately this changes the behavior of the toolbar. With the code change all calls to CreateMenuItem creates a menu item on the main toolbar and not the one created in code.

Major Tom

herilane
10-12-2004, 02:26 PM
You've changed two things in this line of code.
1. You added CType to fix the late binding issue.
2. You changed cbcParant.Controls to cbcParant.Parent.Controls
.
#2 is what's causing your problems; switch back to cbcParant.Controls and it should work properly.

Mike Rosenblum
10-12-2004, 02:50 PM
Also, how is 'cbTarget' declared?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum