View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Markus Ohnmacht Markus Ohnmacht is offline
external usenet poster
 
Posts: 1
Default Ribbon UI onAction causes macro to run twice, with warning

Hello guys,

I get the same problem.
I changed the code as Jim said, but then i get an error that the macro
"MyMacro" can't run and the macro may not available or the macros are
disabled.

Macros are enabled for sure.

It's confusing me.


How can i fix it?


Thanks
Markus


"Jim Rech" wrote:

You don't need the parens in the onAction, although I don't know if they do
any harm. But for sure change your code to this:

Sub MyMacro(control As IRibbonControl)
MsgBox "Hello world"
End Sub

--
Jim
"chelovik" wrote in message
...
|I have a very simple macro on an Excel2007 workbook, that reads:
| Sub MyMacro
| msgbox "Hello world"
| End Sub
|
| Having added a customUI to this workbook (.xlsm), with a button that
reads:
| <button id="customButton" label="Run my macro" onAction="MyMacro()" /
|
| ... when I press the button from the ribbon, the macro runs twice, and I
get
| a dialogbox that shows a heading of: "Microsoft Visual Basic", and a
message
| that simply reads "400" (a "critical" icon is also displayed)
|
| I've opened the xlsm file (by renaming it as .zip), and have been through
| all the xml files, and there is only one reference to the macro throughout
| all the files. Also, the workbook itself as only the one macro, no other
code.
|
| I have also restarted my PC incase there was a memory leak or other
| corruption, but still the same problem
|
| Has anyone had a similar problem? Is there a fix?
|
| I woudl gladly go back to Office2003, but my office have made the shift to
| 2007, so I must get this code working
|
| Thanking you in advance
| Paul