[fly]可以把自己的照片做为按钮的图标,文字也支持自定义。[/fly]
Sub 添加图片按钮() Dim gongju As CommandBar, AnNiu As CommandBarButton, i As Byte, pic On Error Resume Next For i = 1 To 4 Set pic = Sheets("SHEET1").Pictures.Insert(ThisWorkbook.Path & "\" & i & ".ICO") '插入图标到工作表 Next i Application.CommandBars("我的新工具").Delete '如果有新工具栏则删除重新建立 Set gongju = Application.CommandBars.Add '新建工具栏 gongju.Visible = True '让工具栏可见 gongju.Name = "我的新工具" '为工具栏命名 For i = 1 To 4 Set AnNiu = gongju.Controls.Add '为工具栏添加按钮 AnNiu.OnAction = "test" '为按钮指定程序 AnNiu.Caption = "第" & i & "个按钮" '为按钮指定文字标题 AnNiu.Style = msoButtonIconAndCaption '让按钮同时显示文字标题 Sheet1.Pictures(i).Copy '复制图标 AnNiu.PasteFace '粘贴到按钮 Next i For Each pic In Sheets("SHEET1").Pictures '删除工作表中的图片 pic.Delete Next pic End Sub Sub test() MsgBox "按钮!" End Sub
[此贴子已经被作者于2008-2-11 9:09:31编辑过] |