如何在我的AddIns菜单(Excel VBA)中重新定位自定义命令button?

我在我的Excelfunction区的AddIns菜单中创build一个自定义命令button。 问题是我的代码正在创build命令行左下angular的button(它正确地放在AddIns菜单中)。 我怎样才能重新定位我的命令button,在我的AddIns菜单的左上angular?

Private Sub Workbook_AddinInstall() Dim iContIndex As Integer On Error Resume Next 'Just in case 'Delete any existing menu item that may have been left Application.CommandBars("Worksheet Menu Bar").Controls("Compare").Delete 'Pass the Index of the "Format" menu item number to a Variable. iContIndex = Application.CommandBars.FindControl(ID:=30006).Index 'Add the new menu item and Set a CommandBarButton Variable to it. 'Use the number passed to our Integer Variable to position it. Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add(Before:=iContIndex) With cControl .FaceId = 585 .Caption = "Compare" .Style = msoButtonIconAndCaption .OnAction = "CompareFS" End With On Error GoTo 0 End Sub 

要控制function区上的位置,您应该使用function区自定义function。 http://www.rondebruin.nl有你需要知道的关于定制色带的知识。