![]() |
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 |
All times are GMT +1. The time now is 11:23 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com