ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   assign macro to button programmatically (https://www.excelbanter.com/excel-programming/403407-assign-macro-button-programmatically.html)

Zone[_3_]

assign macro to button programmatically
 
I have a button on my worksheet from the Forms toolbar. I know I can use
ActiveSheet.Buttons(1).Caption="My Text" to set the button's caption. But
how do I set the button's macro to sub SpeakMsg? Excel XP. Thanks, James



Helmut Weber

assign macro to button programmatically
 
Hi Zone

Sub Macro1()
ActiveSheet.Shapes("Button 1").OnAction = "testB"
End Sub


--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP

Zone[_3_]

assign macro to button programmatically
 
Many thanks and regards to Munich

"Helmut Weber" wrote in message
...
Hi Zone

Sub Macro1()
ActiveSheet.Shapes("Button 1").OnAction = "testB"
End Sub


--

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Vista Small Business, Office XP





All times are GMT +1. The time now is 01:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com