ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   HOW CAN I WRITE A CODE TO A COMMANDBUTTON CREATED PROGRAMMATICALLY (https://www.excelbanter.com/excel-programming/412435-how-can-i-write-code-commandbutton-created-programmatically.html)

Kozete

HOW CAN I WRITE A CODE TO A COMMANDBUTTON CREATED PROGRAMMATICALLY
 
My first question is how can I write a code to A CommandButton added by the
code below.

Private Sub Workbook_Open()

Set MyCommandButton = UserForm1.Controls.Add
("Forms.CommandButton.1", "CommandButton1" )

End Sub


My second question is, is there a way to create a UserForm programmatically?
(As my project above, I had to create a UserForm manually first and then
invoked the code above to add a CommandButton to my UserForm.)


--
Kozete

Rui

HOW CAN I WRITE A CODE TO A COMMANDBUTTON CREATED PROGRAMMATICALLY
 
Kozete

Have a look at this page as I think it will answer both your questions.

http://www.tek-tips.com/faqs.cfm?fid=5757

Cheers
Rui

"Kozete" wrote:

My first question is how can I write a code to A CommandButton added by the
code below.

Private Sub Workbook_Open()

Set MyCommandButton = UserForm1.Controls.Add
("Forms.CommandButton.1", "CommandButton1" )

End Sub


My second question is, is there a way to create a UserForm programmatically?
(As my project above, I had to create a UserForm manually first and then
invoked the code above to add a CommandButton to my UserForm.)


--
Kozete



All times are GMT +1. The time now is 09:00 AM.

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