index > Visual Basic for Applications (VBA) > Method 'OnAction' of object 'CommandBarButton' Failed

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..
gurub

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

Peter Mo.

Peter Mo.
Thanks for the reply.. Only one user is experiencing this issue..His office version is 2003.
gurub

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.

Peter Mo.
Hi,
I'll try this on the user machine and will let you know..Thanks for looking into it..
gurub
reply 5

You can use google to search for other answers

 

More Articles

• Table Caption Property
• Copying rows inside table with vba
• Collections of control - evaluating the name of a control that ha...
• "Bizzare" Sendkey Code in Excel
• variable declarations
• duplicate records with childs
• ADO Recordsets
• Reg: Need an API which reads GDI Object count from Task Manager
• Disable "Unprotect Document" in Tools Menu Item
• macro doesn't run on open
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

• Control Break Trap will not work whilst
• Accessing OLE object properties (powerpo
• Tic Tac Toe Game
• VBA runs slowly in Excel 97
• VBA and VB
• Calling procedures from a procedure
• No Database Type
• Word Macro Runtime Error
• Standard Difference Function
• Access and DWGs
• Openning Excel from Access 97
• Using the API of Visio to open a Custom
• How print picture
• Getting Data of HTML page
• SetSourceData frustration

Hot Articles

• Custom Date Picker Control
• VBA Module to DLL
• Multithreading, Callback & VBA in Po
• Require Basic Excel Sorting Macro To Be
• Limit Macro to current workbook
• Access 2003 - Retrieving computer inform
• Output excel file to PDF format
• Suppress Linked View Unique Record Popup
• Writing To Text File Without Quotes
• After refresh, trigger script, then clos
• Select line of text in Word documents
• About Error:"Unable to Set Visible
• VLookup returns "Error 2042" w
• VBA HELP ON WORKSHEET
• Access report using VBA

Recommend Articles

• How To Transfer Data to ADO Data Source
• How to pop data from a table in MS Acces
• additem issue with populating a combobox
• Another SendKeys
• Can anybody explain this code for me ???
• Get Excel Sheet Names
• Newsbyte: VSTO "Cypress" Offic
• Runtime Error '1004': Copy of method Wor
• Printing help
• COM+ Error ,Error Code = 0x8004270f ,M
• Dump data into 2 databases automatically
• Custom Format Data inside a Cell
• SubForm - ActiveCell
• Problem with Query in VBA code : Object.
• A Control's Visible property does make t