View Full Version : Unable to resize Commandbar
The code creates a menu in the commandbar, where all of the buttons reach too far, however I am not able to resize it via the .Width command.
I have tried in Word 2007 and 2010.
Can you help me?
Thanks
Daniel
Sub Menu()
Dim cbrWiz As CommandBar
Dim ctlInsert As CommandBarButton
On Error Resume Next
Set cbrWiz = CommandBars("Menu")
If cbrWiz Is Nothing Then
Err.Clear
Set cbrWiz = CommandBars.Add("Menu")
' Add button control.
For x = 1 To 20 Step 1
Set ctlInsert = cbrWiz.Controls.Add
With ctlInsert
.Caption = "The text in this field is very long................" & x
.Style = msoButtonCaption
.TooltipText = "Macro" & x
.Tag = "NewMacros" & x
.OnAction = "Button" & x
End With
Next x
cbrWiz.Visible = True
cbrWiz.Width = 60
Else
cbrWiz.Visible = True
End If
End Sub
Frosty
04-25-2011, 10:18 AM
You need to look up the Fluent UI ribbon interface. Commandbars are dinosaurs in this version.
Your commandbar, such as it is, is showing up under the Addins tab, but much of the properties of the commandbars are simply there for legacy, not because they actually do anything in these versions.
Thank you for your reply.
Ok, whatever does the job makes me happy.
Can you link to some code, which can tricker the Fluent UI ribbon interface, so that I can add buttons to my application?
Thanks
Daniel
Frosty
04-25-2011, 12:38 PM
Can't really post links unless I know what "does the job" for you. Here are some generic links (microsoft and one of the regulars here-- Greg Maxey) which will have some sample projects.
But you need to be a little more specific than "add buttons to my application" since, technically, your above code already did that... it simply put the buttons in the Addins Tab.
http://msdn.microsoft.com/en-us/library/aa338202%28office.12%29.aspx
(the ribbon stuff is down near the bottom)
http://gregmaxey.mvps.org/word_tips.htm
The Fluent UI ribbon interface is interesting. However I cannot find some simple code without a XML document aside, which does the same job as the code above.
It is ok, if the XML code is embedded in the VBA code.
The reason for it being easy implementation of my macro code on the computers using it, I just overwrite the normal.dotx file.
It also needs to be 100% compatible with Word 2007.
Is that possible?
Frosty
04-27-2011, 04:24 AM
If you want a user interface, you will need at least some of it in XML. If you are distributing a replacement normal.dotm to distribute your code, you should be able to add buttons there too.
I don't believe it is possible in 2007 or 2010 to simply distribute a .bas file with an autoexec routine in it, have your users import into "normal" and have a fully functional UI.
Custom UI Editor at openxml.org will make it a lot easier. But this is a difficult transition (from 2003 to 2007), even for the "simplest" of macros. Time to start reading and learning, I think.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.