SOS: Excel custom Toolbar

H

hedonists

Hi,
I created a custom Excel Toolbar with VBA. It worked in Windows Excel, but
the buttons failed to load in Mac Excel. The error message says
Run-time error '-2147483640(-7FFFFFF8)':
Method 'FaceId' of object 'CommandBarButton' failed

If I comment out the .FaceId = 642
Then the error message becomes
Method 'OnAction' of object 'CommandBarButton' failed
Can someone help me to find what is
wrong with the code?
Thank you very much.

---------------------------------------------
Private Sub CreateDesignToolbar()
Dim TBar As CommandBar
On Error Resume Next
Application.CommandBars("Lenses Design").Delete
On Error GoTo 0
Set TBar = Application.CommandBars.Add
With TBar
.Name = "Lenses Design"
.Protection = msoBarNoCustomize
.Position = msoBarFloating
.Visible = True
End With
Call AddDesignButton
End Sub


Sub AddDesignButton()
Set NewBtn1 = Application.CommandBars("Lenses
Design").Controls.Add(Type:=msoControlButton)
With NewBtn1
.FaceId = 642
.OnAction = "ThisWorkbook.LensDesign"
.Caption = "Design"
.TooltipText = "Design aerodynamic lenses"
.Style = 3
End With
Set NewBtn2 = Application.CommandBars("Lenses
Design").Controls.Add(Type:=msoControlButton)
With NewBtn2
.FaceId = 2174
.OnAction = "ThisWorkbook.OtherSizes"
.Caption = "More"
.TooltipText = "Examine other sizes"
.Style = 3
End With

Set NewBtn3 = Application.CommandBars("Lenses
Design").Controls.Add(Type:=msoControlButton)
With NewBtn3
.FaceId = 688
.OnAction = "ThisWorkbook.Reset"
.Caption = "Reset"
.TooltipText = "Reset to default parameters"
.Style = 3
End With

Set NewBtn4 = Application.CommandBars("Lenses
Design").Controls.Add(Type:=msoControlButton)
With NewBtn4
.FaceId = 49
' .OnAction = "ThisWorkbook.OtherSizes"
.Caption = "Help"
.TooltipText = "Help"
.Style = 3
End With
End Sub
------------------------------------------------
 

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