robje
07-07-2008, 04:18 AM
Hello,
When I try to add code in runtime after clicking a button, excel says it has come acros an error and it has to shut down.
I'm using excel 2003 sp2
and this is the code I'm using:
With Workbooks(BestandsNaam).VBProject.VBComponents("Blad2").CodeModule
.InsertLines .CountOfLines + 1, "private Sub " + "bLeverantieToevoegen" + typenVerzameling(typenVuller) + "_click()"
.InsertLines .CountOfLines + 1, " Sheets(""Algemeen"").Cells(1, 1).Value = ""Woning"" "
.InsertLines .CountOfLines + 1, " Sheets(""Algemeen"").Cells(1, 2).Value = ""Type Woning leverantie"" "
.InsertLines .CountOfLines + 1, " Sheets(""Algemeen"").Cells(1, 3).Value = ""Type Woning Uren"" "
.InsertLines .CountOfLines + 1, " Sheets(""Algemeen"").Cells(1, 4).Value = " + """" + "Leverantie Details(Groep: " + groepNaam + ", Type: " + typeNaam + "(" + nummer + "))" + """"
.InsertLines .CountOfLines + 1, " Sheets(""Algemeen"").Cells(1, 5).Value = " + """" + "Uren Details(Groep: " + groepNaam + ", Type: " + typeNaam + "(" + nummer + "))" + """"
.InsertLines .CountOfLines + 1, " Load Selecteren"
.InsertLines .CountOfLines + 1, " Selecteren.Show"
.InsertLines .CountOfLines + 1, "End Sub" & Chr(13)
End With
Can anyone see what I'm doing wrong here?
With Kind regards,
Rob
Edited by Aussiebear: To include code within the VBA Tags
When I try to add code in runtime after clicking a button, excel says it has come acros an error and it has to shut down.
I'm using excel 2003 sp2
and this is the code I'm using:
With Workbooks(BestandsNaam).VBProject.VBComponents("Blad2").CodeModule
.InsertLines .CountOfLines + 1, "private Sub " + "bLeverantieToevoegen" + typenVerzameling(typenVuller) + "_click()"
.InsertLines .CountOfLines + 1, " Sheets(""Algemeen"").Cells(1, 1).Value = ""Woning"" "
.InsertLines .CountOfLines + 1, " Sheets(""Algemeen"").Cells(1, 2).Value = ""Type Woning leverantie"" "
.InsertLines .CountOfLines + 1, " Sheets(""Algemeen"").Cells(1, 3).Value = ""Type Woning Uren"" "
.InsertLines .CountOfLines + 1, " Sheets(""Algemeen"").Cells(1, 4).Value = " + """" + "Leverantie Details(Groep: " + groepNaam + ", Type: " + typeNaam + "(" + nummer + "))" + """"
.InsertLines .CountOfLines + 1, " Sheets(""Algemeen"").Cells(1, 5).Value = " + """" + "Uren Details(Groep: " + groepNaam + ", Type: " + typeNaam + "(" + nummer + "))" + """"
.InsertLines .CountOfLines + 1, " Load Selecteren"
.InsertLines .CountOfLines + 1, " Selecteren.Show"
.InsertLines .CountOfLines + 1, "End Sub" & Chr(13)
End With
Can anyone see what I'm doing wrong here?
With Kind regards,
Rob
Edited by Aussiebear: To include code within the VBA Tags