Excel 2010 VBA several Commandbars properties do not appear to work

Stephen Ford 1 Reputation point
2022-04-27T15:08:04.813+00:00

Some Commandbars properties do not appear on a generated toolbar. The image below shows a Toolbar on the Addins tab. The code that generated it is included.

The code commented out does not make any obvious difference to the look and feel of the toolbar.

197029-excel-vba-custom-toolbar-problem.png

I copied the code below from a website and applied my own modifications. Then I found that some properties seemed not to work eg the tooltip.

The plan is to have four buttons.

I note that the Ribbon is now being used but it appears there is no VBA interface. A search for anything about obsolete properties of the Commandbars object did not find any info that I recognised. Have the properties shown in the code just been removed from VBA?

Clicking the button starts the required macro, so clearly the OnAction and FaceID properties still work.

Sub Ahs_CreateMyTool()  
  
'Make the toolbar  
Set cbMyTool = CommandBars.Add  
cbMyTool.name = "ACE"  
  
'Add a buttons to the toolbar  
Set cbbMyButton = cbMyTool.Controls.Add(msoControlButton)  
With cbbMyButton  
  .Caption = "my caption"  
  .DescriptionText = "my description"  
  .FaceId = 3359  
  .OnAction = "ahs_ShowReconForm"  
  .TooltipText = "Reconcile"  
End With  
  
'Before we finish, the toolbar gets a name, width and  
'is put on the screen.  
With cbMyTool  
   .name = "ACE"  
'   .Left = Application.ActiveWindow.Width  
'   .Top = Application.ActiveWindow.Height  
   .Visible = True  
'   .Width = 300  
End With  
  
Exit Sub  
ErrorHandle:  
MsgBox Err.Description & " CreateMyTool", vbOKOnly + vbCritical, "Error"  
Resume Next  
  
End Sub  
Developer technologies Visual Basic for Applications
{count} votes

1 answer

Sort by: Most helpful
  1. Stephen Ford 1 Reputation point
    2022-04-28T09:48:04.24+00:00

    Thank you for those references. I have skimmed through them and note many of the authors comments or apparent exasperation - or maybe just resignation(?) I have to take my hat off to them for staying with it long enough to create ribbon with a button...

    I suppose it was inevitable that XML would crawl out of the woodwork at some time or another. Progress and all that...

    I was hoping to sidestep the need to study XML becasue it's yet another language that requires quite a lot of study to achieve anything useful. The user is then left in the unenviable position of either diving in head first fully committed, or doing nothing and needing a far less innovative plan.

    In reality, the Toolbar I want to use should only need a very small amount of programming; but the IT brigade have extended the complexity of IT systems to way beyond the capabilities of the user becasue they can, as compared with whether it's really necessary or helpful.

    Since doing a fair bit of work on MS Office and realising the totally different object models between all the apps in the suit, it makes one wonder what the development teams where thinking about. It seems they all went into their own development huddles, and when they emerged were surprised they had all developed different solutions to the same problem.

    I am sure I will find time eventually to visit XML (assuming I live long enough) but at present it's far too involved for such a simple problem.

    However, I am grateful for your reply.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.