MrExcel Publishing
Your One Stop for Excel Tips & Solutions

VBA and Excel 2000

Posted by Dan Macphee on September 15, 2001 11:46 PM

I am transferring a program from Excel 97 to Excel 2000
and I have come across a stumbling block. My OnAction property from Excel 97 doesn't work to call a macro in 2000 (attaching a macro to a custom Commandbar button). I have checked into the problem and may have to re-code the whole CommandBar- just seeking your advice, is there a better way?

Posted by Damon Ostrander on September 17, 2001 4:22 PM

Hi Dan,

OnAction exists in Excel 2000 the same as in 97. One way that this could go awry however is if you accidentally insert the code you want to execute into a worksheet or workbook event code pane rather than into a macro module. If you can get to the code by right-clicking on the worksheet's tab and selecting View Code, you have put it in the wrong place. The same is true of right-clicking on the Excel icon at the left edge of the Excel Menu Bar--your code should not be there either. To put it into a macro module, in the VBE insert a new module (Insert -> Module) and paste the code into the code pane there. This is a VERY common cause of such problems.

I hope this helps.