I found the answer to this problem after much testing and a long search for an answer. I found several examples of people having this problem and lots of misleading suggestions that did not provide the answer to the real cause of the problem.
To Recap the problem was
VB code would execute without a problem on some computers and would not work on others. When a code file was opened and the macro ran to load custom menus it failed at the OnAction Property of the CommandBars setting where the code would assign an action to a Menu item. This produced a Run-Time error with this error message.
Run-time error '-2147467259 (80004005)':
Method 'OnAction' of object '_commandBarButton' failed
The resolution to this error is incredibly simple, well at least once I discovered the answer. It is almost unbelievable that the answer is not better documented on MSDN and in more forums dealing with Excel
VB.
Now to get to the answer, this was a program used by several users in our office on different PCs. When the program was opened the first time it required the user to click the Macro Warning message to "Allow" Macros to run. Once setup the program was to start automatically when excel started by writing a shortcut in the Excel Startup folder. However many users were still going to the file on the server and opening then clicking "Disable" on the Macro Warning Message Dialog.
This is the cause of the problem and the key to the Answer. When the "Disable Macros" is selected on the Macro Warning message it adds the file name to the Excel "List of Disabled Components" Making a copy of the file or opening it from a different source would permit the program to work as it was not identified as the same component, but the file name would still be retained in the list of disabled components. The file must be cleared from the List of Disabled components in order for it to run.
To access the list of disabled components you first have to find it and it is not in an obvious location. Open the "Help" Menu then select "About Microsoft Excel". On the About Microsoft Excel Dialog in the lower right corner is a button "
Disabled Items..." Clicking this button opens the "Disabled Items" List. If you see your
VB Code file name in this list, it is registered as a Disabled Item and some CB commands may not execute. Select the name of your file and click the "
Enable" button. This will remove the item from the Disabled Items list and allow it to function as designed on the users PC.
After removing the file from the disabled items list, you must educate your users on opening and running your code files. At least the next time they report having this problem you will know what to check.