Adding a control of type msoControlActiveX

A

Andy Weston

Hi,

I am adding an ActiveX control to an Office toolbar by
adding a control of type msoControlActiveX as in the code
below.

I later assign the class id of my ActiveX control to the
ActiveX control

AXControl.ControlCLSID = "{xxxxxxxx-xxxx-xxxx-xxxx-
xxxxxxxxxxxx}"

My problem is that I cannot control the size of the
commandbar.

When I create the control as follows the commandbar is
resized:

Set m_oBarControl = m_oCmdBar.Controls.Add
(Type:=msoControlActiveX, Temporary:=True)

The commandbar width and height are read only so I do not
appear able to resize it. I can resize it manually. If I
add a standard control type such as a button the command
bar sizes correctly.

Can anyone help with a solution?

I'm actually working in C++ using ATL but here is the
same in VB.
Code snipet:

Set m_oCommandBars = m_oWordApp.CommandBars

Dim strCBarName As String
strCBarName = "Test Toolbar"
Set m_oCmdBar = m_oCommandBars.Add(Name:=strCBarName,
Position:=msoBarTop, MenuBar:=False, Temporary:=True)
m_oCmdBar.Visible = True

Set m_oBarControl = m_oCmdBar.Controls.Add
(Type:=msoControlActiveX, Temporary:=True)
 
A

Andy Weston

I have found that my problem is not adding the ActiveX
control to the toolbar, that is working just fine.

It is a more generic problem whereby I find that the
Height property of commandbar controls of type
msoControlActiveX does not give the expected results. It
works in Office 9 but fails to respond in Office XP.

The height may be increased but fails when decreased in
size. The following line of code executes successfully:
m_oBarControl.Height = 45

but the commandbar control does not respond accordingly.

I am tending towards the oppinion that this may be a bug.

Code snippet:

Set m_oBarControl = m_oCmdBar.Controls.Add
(Type:=msoControlActiveX, Temporary:=True)

m_oBarControl.Visible = True

m_oBarControl.Width = 290
' this setting does not respond as expected
m_oBarControl.Height = 45
 

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