Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Programming to the VBE - Help
Hi all, i am trying to use the code below to insert some code into the
worksheet. It works fine with F8 and F5 but when i run the code excel closes due to an error.??? Can anybody help me with this please ?? Sub BBBStdR() ' On Error Resume Next CreateEventProcedure On Error Resume Next Application.OnTime Now + TimeValue("00:00:02"), "MoveKTLToArchiveR" End Sub Sub CreateEventProcedure() Dim VBProj As VBIDE.VBProject Dim VBComp As VBIDE.VBComponent Dim CodeMod As VBIDE.CodeModule Dim LineNum As Long, sName As String, myKTL As String myKTL = "90ZA0810" sName = Workbooks("Status-Report-" & myKTL & ".xls").Sheets("ALL LC PARTS").CodeName Set VBProj = ActiveWorkbook.VBProject Set VBComp = VBProj.VBComponents(sName) Set CodeMod = VBComp.CodeModule With CodeMod LineNum = .CreateEventProc("BeforeDoubleClick", "Worksheet") LineNum = LineNum + 1 .InsertLines LineNum, "Cancel = True" .InsertLines LineNum, "Worksheets(""0908 RMT"").Activate" .InsertLines LineNum, "Application.ActiveSheet.ShowAllData" .InsertLines LineNum, "Cancel = True" End With End Sub -- Les |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
programming | Excel Programming | |||
Programming | Excel Programming | |||
Programming IDE | Excel Programming | |||
vba programming | Excel Programming | |||
How to add via programming ? | Excel Programming |