其实对于这个问题,一是涉及FACEID的问题,还有可能是涉及加载图片的问题,请参:http://club.excelhome.net/dispbbs.asp?BoardID=23&replyID=333944&id=44804&skin=0 对于删除问题,可以使用代码进行删除,请参阅: Private Sub Document_Close()
On Error Resume Next
Application.CommandBars("Text").Controls("Test").Delete '恢复原有菜单
End Sub
'----------------------
Private Sub Document_Open()
Dim Half As Byte
On Error Resume Next
Dim NewButton As CommandBarButton
Application.CommandBars("Text").Controls("Test").Delete '预防性删除
Half = Int(Application.CommandBars("Text").Controls.Count / 2) '中间位置
Set NewButton = Application.CommandBars("Text").Controls.Add(Type:=msoControlButton, Before:=Half)
With NewButton
.Caption = "Test" '命令名称
.FaceId = 100 '命令的FaceId
.Visible = True '可见
.OnAction = "MySub" '指定响应过程名
End With
End Sub
'----------------------
Sub MySub()
MsgBox "It's A Test For CommandBars(""Text"")!", vbOKOnly + vbInformation
End Sub
'----------------------
Sub ComReset() '重新设置右键菜单,彻底恢复默认设置
Application.CommandBars("Text").Reset
End Sub
'----------------------
|