devilishblueyes
2011-05-23 18:05:08 UTC
I have no problem getting the code to work to add new objects to a form. I also don't have any problem getting InsertLines to add dynamic code to the form's module. The code appears in the form's module, just like I'd like.
So the command button shows up on the form and the Click Event shows up in the form module and looks like this:
Private Sub CommandButton1_Click()
MsgBox "Hello"
End Sub
But when I click on CommandButton1, it is like Excel doesn't even know I've written a Click Event for the button. I've made sure to reference the Microsoft Visual Basic for Applications Extensibility library. And I made my changes to the macro settings to trust access to the vba project object model. But it still doesn't work!
Does anyone know why it isn't recognizing my Click Event? I'm using his 100 CommandButtons example and it just seems like something just was forgotten to be mentioned in the book or something. Either that or I'm doing something wrong.
I know this isn't the easiest of topic, but I'd greatly appreciate any help because I'm trying to use this concept to add more text boxes and combo boxes to a form in a VBA project that I'm working on. My complex form has 17 rows of objects. Each row enters a line of instructions on an Excel worksheet. But with 17 rows of objects, the form is getting pretty big. So I created a spin button to hide the first row and add a new row and move the rest of the rows up. Selections of the combo boxes bring up other forms to quickly enter data for making calculations and such. So when I add a new row, the new objects have to have event procedures that work to bring up the new forms. I've solved adding the objects, etc...just not getting the events to work. I've thought about creating a work-around just staying with 17 instruction rows and not adding any new objects and just storing the data to an array to work with for certain portions. So for example if I add an 18th row, the 1st row that would have gotten hidden would get added to the array. But that would involve completely rewriting major portions of my program to work with the array data instead of the form's objects. So if someone can help me out this would save me a lot of extra work.