Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default CommandBarButton.OnAction prop fires when set? Arg!

Hi Kevin,

I doesn't matter what I put there. My original program
called "myprog.xla!mysub" which worked but fired when it
was declared and then never fires when the button is
clicked. I only want it to fire when the user clicks the
button. I'm stumped. Any other ideas? Thanks for the
feedback.


The OnAction property of a commandbar should *not* be the actual code
that you want to run when the button is clicked, but instead should be
a reference to a routine that you want to run.

So instead of:

cmdOpen.OnAction = MsgBox("Runs When First Set!")

You need to use:

cmdOpen.OnAction = "'" & ThisWorkbook.Name & "'!SomeMacroName"


'Put in a standard module
Sub SomeMacroName()
MsgBox "Runs when button is clicked!"
End Sub


Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk

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
R/T 1004 - Unable to get Button prop of Ws Class Jim May Excel Discussion (Misc queries) 3 January 2nd 08 05:19 PM
TEMPLATE IN EXCEL FOR MONTHLY PAYMENTS FOR MORE THAN ONE PROP tb New Users to Excel 1 January 4th 05 04:20 PM
Drop Down Selection fires a module? John Excel Worksheet Functions 1 December 6th 04 09:17 PM
Thanks - creating a commandbarbutton with a custom bitmap Kris Van Baelen Excel Programming 0 July 11th 03 08:24 PM
creating a commandbarbutton with a custom bitmap Tom Ogilvy Excel Programming 0 July 11th 03 07:50 PM


All times are GMT +1. The time now is 05:32 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"