ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Create Command Button from Code (https://www.excelbanter.com/excel-programming/271580-re-create-command-button-code.html)

Bruce B[_2_]

Create Command Button from Code
 


Thanks John!

I decided to use the Forms command button.

I added the following code:

Sub Macro8()

ActiveSheet.Buttons.Add(100, 40, 78.75, 27.75).Select
Selection.Name = "x"
Selection.Caption = "xxxxxx"
Selection.OnAction = "subX"

End Sub

Sub subX()

Debug.Print "x"


End Sub

This works fine.

However, how do I reference the button or find out property values? I
tried several things in subX, such as:

Debug.Print "cap: " & x.Caption

but got an error.

I tried called using:
subX(Me)
sub subX(byval o as object) 'and as commandbutton
but still got error (object related).

Do you know how I can do this?

Thanks again.

- Bruce





*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 03:15 PM.

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