So the key parts of the code are
So with a picture named "testicon" on sheet 1, I get a bar/button/icon.Sub test() Dim cmbTargetMenuBar As CommandBar Dim cbbNewMenuItem As CommandBarButton Set cmbTargetMenuBar = CommandBars.Add With cmbTargetMenuBar .Visible = True Set cbbNewMenuItem = .Controls.Add(msoControlButton, , , , False) With cbbNewMenuItem .Caption = "Test caption" .OnAction = "testroutine" .Style = msoButtonIconAndCaption Sheets(1).Shapes("testicon").Copy .PasteFace End With End With End Sub
You'll get a "Method... failed" error if:
there's nothing on the clipboard
the clipboard contents isn't compatible
Although, using similar code, I had this error occasionally (actually rare and randomly) when running from Excel97 - I could never replicate it under test conditions and since the project spec specified 2000+, I didn't chase it down.





Reply With Quote