Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dear All;
I am attempting to add code to buttons on a userform that exists as part of an excel add-in. I have created the rest of the code, and it all works OK, however I have changed from a dynamically created userform, created at design time, to an existing userform with controls and sizes added at runtime so that I can password protect the project. Unfortunately, whereas in the dynamic userform, I could use the following code: Set frmPrintAll = ThisWorkbook.VBProject.VBComponents.Add(3) With frmPrintAll '... Rest of code to dynamically create size, buttons, etc ....' With frmPrintAll.CodeModule x = .CountOfLines .InsertLines x + 1, "Sub CommandButton1_Click()" .InsertLines x + 2, " intClicked=-1" .InsertLines x + 3, " Unload Me" .InsertLines x + 4, "End Sub" .InsertLines x + 5, "Sub CommandButton2_Click()" .InsertLines x + 6, " intClicked=1" .InsertLines x + 7, " Unload Me" .InsertLines x + 8, "End Sub" End With When I attempt to modify the .CodeModue on the non-dynamically created userform, nothing happens. I have a dimension statement at the start of the code, which is accessed in the following way: dim frmPrintAll as new frmPrintAll I have tried created static code with the above details in them, however when you click on the buttons, despite them being called CommandButton1 and CommandButton2 (As far as I can tell, anyway) nothing happens. Does anybody have any solutions to this puzzling problem? Any response will be much appreciated. Peter Street OLE Alliance. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
buttons and boxes in userform | Excel Discussion (Misc queries) | |||
Dynamically create worksheets in Excel based off existing data? | Excel Discussion (Misc queries) | |||
How can I create and display a chart dynamically on a UserForm wi. | Charts and Charting in Excel | |||
How to get Maximize and Minimize buttons on Userform | Excel Programming | |||
How to add textbox/buttons to an UserForm | Excel Programming |