Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Application Crash Whie adding Code lines using VBA
Hi,
Executing the code given below throws an error: "Microsoft Office Excel has encountered a problem and needs to close. We are sorry for the inconvenience." But If I remove first insertLine statement that is ".InsertLines LineNum, "Private Sub.........." the program is excuting fine. Please help me on this. Thanks!! Sub WriteEventHandler(LabelName As String) Dim LineNum As Long Const DQUOTE = """" Set RenameCodeMod = ActiveWorkbook.VBProject.VBComponents("Sheet1").Co deModule With RenameCodeMod LineNum = .CountOfLines + 1 .InsertLines LineNum, "Private Sub " + LabelName + "_DblClick(ByVal Cancel As MSForms.ReturnBoolean)" LineNum = LineNum + 1 .InsertLines LineNum, " CurName = " + Trim(LabelName) + ".Caption" LineNum = LineNum + 1 .InsertLines LineNum, " newname = InputBox(" + DQUOTE + "Enter new name for " + DQUOTE + " + CurName, " + DQUOTE + "Rename" + DQUOTE + ", CurName)" LineNum = LineNum + 1 .InsertLines LineNum, " If Len(Trim(newname)) 0 Then " + Trim(LabelName) + ".Caption = Trim(newname)" LineNum = LineNum + 1 .InsertLines LineNum, "End Sub" End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
adding code lines with vba code | Excel Programming | |||
Application makes VBE crash. How do I troubleshoot? | Excel Programming | |||
Adding code to control on form causes Excel to crash | Excel Programming | |||
Adding code to a control on a form causes excel to crash | Excel Programming | |||
Application.Quit en Excel crash | Excel Programming |