Method 'OnAction' of object 'CommandBarButton' Failed

One of the users is getting the following error message:

Runtime Error '2147467259 (80004005)':

Method 'OnAction' of object 'CommandBarButton' Failed.

The following is the code:

Private Sub Workbook_Open()

Dim MyCommandBar As CommandBar
Dim MyControl As CommandBarButton

For Each MyCommandBar In Application.CommandBars
If MyCommandBar.Visible = True Then
If MyCommandBar.Name = "Worksheet Menu Bar" Then
Set MyControl = MyCommandBar.Controls.Add(msoControlButton, , , , True)
MyControl.Caption = "GFS BW Printing"
MyControl.Style = msoButtonCaption
MyControl.Visible = True
MyControl.OnAction = "GFS_Printing_Macro"
End If
End If
Next
End Sub

Any help will be appreciated...Thanks in advance..
[962 byte] By [gurub] at [2007-12-25]
# 1

Works for me in Excel. What version of Office are they running?

Peter Mo.

PeterMo. at 2007-9-3 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 2
Thanks for the reply.. Only one user is experiencing this issue..His office version is 2003.
gurub at 2007-9-3 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 3

Hi

I didn't have any problems with either Excel 2003 SP2, or 2000 SP3.

I found the following at ...

http://www.asap-utilities.com/blog/index.php/2005/09/19/method-add-of-object-commandbarcontrols-failed/

Often this is a corrupt or bloated toolbar file. A *normal* size is < 30 kb. The .xlb file has all Toolbar customization in it.

You can try the following:

Close Excel

Do a search for .xlb in windows
Rename the file you find, e.g. rename the .xlb to .bac (my file is named Excel10.xlb in 2002, Excel11.xlb in 2003)
If you make your own toolbars or add buttons to the others this file is important (backup it so you can restore it)
Deleting the file or renaming will do no harm on your system, Excel will automaticly create a new one for you.
(However you lost your customization remember that)

Start Excel

I've got reported back from several people that this did the trick

--

I can't check it as I'm not seeing the problem, but it didn't seem to cause me any problems either.

Regards

Peter Mo.

PeterMo. at 2007-9-3 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 4
Hi,

I'll try this on the user machine and will let you know..Thanks for looking into it..
gurub at 2007-9-3 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 5
This didn't resolve the issue...I asked cust to reinstall MS Office and hope this will resolve...thanks for everybody who responded...
gurub at 2007-9-3 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...