Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Ribbon UI onAction causes macro to run twice, with warning

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 533
Default Ribbon UI onAction causes macro to run twice, with warning

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Ribbon UI onAction causes macro to run twice, with warning


Much better if you state the onaction like this:

.OnAction = ThisWorkbook.name & ("!MyMacro")


--
The Code Cage Team

Regards,
The Code Cage Team
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
The Code Cage Team's Profile: http://www.thecodecage.com/forumz/member.php?userid=2
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=33253

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Ribbon UI onAction causes macro to run twice, with warning

OnAction = ThisWorkbook.name & ("!MyMacro")

You cannot put macro code in RibbonX.

Markus, can you send me an example that fails?

--
Jim
"The Code Cage Team" wrote in
message ...
|
| Much better if you state the onaction like this:
|
| OnAction = ThisWorkbook.name & ("!MyMacro")
|
|
| --
| The Code Cage Team
|
| Regards,
| The Code Cage Team
| 'The Code Cage' (http://www.thecodecage.com)
| ------------------------------------------------------------------------
| The Code Cage Team's Profile:
http://www.thecodecage.com/forumz/member.php?userid=2
| View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=33253
|



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Ribbon UI onAction causes macro to run twice, with warning

Thanks for the answers,

the solution from "Code cage" doesn't work.

@Jim, I sent u an example file. I hope u can fix my problem :)

Bye
Markus

"Jim Rech" wrote:

OnAction = ThisWorkbook.name & ("!MyMacro")


You cannot put macro code in RibbonX.

Markus, can you send me an example that fails?

--
Jim
"The Code Cage Team" wrote in
message ...
|
| Much better if you state the onaction like this:
|
| OnAction = ThisWorkbook.name & ("!MyMacro")
|
|
| --
| The Code Cage Team
|
| Regards,
| The Code Cage Team
| 'The Code Cage' (http://www.thecodecage.com)
| ------------------------------------------------------------------------
| The Code Cage Team's Profile:
http://www.thecodecage.com/forumz/member.php?userid=2
| View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=33253
|


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Ribbon UI onAction causes macro to run twice, with warning

As I emailed Markus, the code was in the ThisWorkbook module. I should have
thought of that...

--
Jim
"Markus Ohnmacht" wrote in
message ...
| Thanks for the answers,
|
| the solution from "Code cage" doesn't work.
|
| @Jim, I sent u an example file. I hope u can fix my problem :)
|
| Bye
| Markus
|
| "Jim Rech" wrote:
|
| OnAction = ThisWorkbook.name & ("!MyMacro")
|
| You cannot put macro code in RibbonX.
|
| Markus, can you send me an example that fails?
|
| --
| Jim
| "The Code Cage Team" wrote
in
| message ...
| |
| | Much better if you state the onaction like this:
| |
| | OnAction = ThisWorkbook.name & ("!MyMacro")
| |
| |
| | --
| | The Code Cage Team
| |
| | Regards,
| | The Code Cage Team
| | 'The Code Cage' (http://www.thecodecage.com)
|
| ------------------------------------------------------------------------
| | The Code Cage Team's Profile:
| http://www.thecodecage.com/forumz/member.php?userid=2
| | View this thread:
http://www.thecodecage.com/forumz/sh...ad.php?t=33253
| |
|
|

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Ribbon UI onAction causes macro to run twice, with warning

Thanks a lot Jim,

it's confusing me.
I also tried the code in a Module and it didn't work. But now everything is
fine.


I go home now.

Cya
Markus


"Jim Rech" wrote:

As I emailed Markus, the code was in the ThisWorkbook module. I should have
thought of that...

--
Jim
"Markus Ohnmacht" wrote in
message ...
| Thanks for the answers,
|
| the solution from "Code cage" doesn't work.
|
| @Jim, I sent u an example file. I hope u can fix my problem :)
|
| Bye
| Markus
|
| "Jim Rech" wrote:
|
| OnAction = ThisWorkbook.name & ("!MyMacro")
|
| You cannot put macro code in RibbonX.
|
| Markus, can you send me an example that fails?
|
| --
| Jim
| "The Code Cage Team" wrote
in
| message ...
| |
| | Much better if you state the onaction like this:
| |
| | OnAction = ThisWorkbook.name & ("!MyMacro")
| |
| |
| | --
| | The Code Cage Team
| |
| | Regards,
| | The Code Cage Team
| | 'The Code Cage' (http://www.thecodecage.com)
|
| ------------------------------------------------------------------------
| | The Code Cage Team's Profile:
| http://www.thecodecage.com/forumz/member.php?userid=2
| | View this thread:
http://www.thecodecage.com/forumz/sh...ad.php?t=33253
| |
|
|


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro - onAction arguments version83 Excel Worksheet Functions 2 April 10th 10 09:59 PM
OnAction macro in another wb Desert Piranha[_96_] Excel Programming 2 August 2nd 06 10:34 PM
.onaction macro call won't work No Name Excel Programming 8 March 3rd 05 09:36 AM
OnAction Cannot find Macro ?? Andrew Kennard Excel Programming 5 December 22nd 04 03:17 PM
ONACTION macro tries to open another workbook jason Excel Programming 2 October 30th 03 10:12 PM


All times are GMT +1. The time now is 10:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"