Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have this code which copies a specific routine into the
Thisworkbook module of a specific workbook. There is code before this routine which I wish not to copy, but I have now added code after this routine. I could use the copy statements for each of the extra routines, but I wondered if there was another way? Public Sub CopySheetChangeEventFromAnyBook _ (ByVal NewWorkbookName As String) 'This will only execute if the calling Workbook is unprotected. Dim SourceCodeModule As VBIDE.CodeModule Dim DestCodeModule As VBIDE.CodeModule Dim wb As Workbook, StartCopyLine As Long Dim NumberOfLines As Long Set SourceCodeModule = _ ThisWorkbook.VBProject. _ VBComponents("ThisWorkbook").CodeModule Set DestCodeModule = _ Workbooks(NewWorkbookName & ".xls").VBProject. _ VBComponents("ThisWorkbook").CodeModule StartCopyLine = SourceCodeModule.ProcStartLine _ ("Workbook_SheetChange", vbext_pk_Proc) NumberOfLines = SourceCodeModule.ProcCountLines _ ("Workbook_SheetChange", vbext_pk_Proc) DestCodeModule.InsertLines DestCodeModule.CountOfLines + 1, _ SourceCodeModule.Lines(StartCopyLine, NumberOfLines) End Sub Could I therefore tell it to start with the "Workbook_SheetChange" routine, and then copy all following routines? Regards. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.786 / Virus Database: 532 - Release Date: 29/10/2004 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unprotect Code Module in Code | Excel Discussion (Misc queries) | |||
code in module A to not execute a Worksheet_SelectionChange sub of another module | Excel Discussion (Misc queries) | |||
copying vba code to a standard code module | Excel Discussion (Misc queries) | |||
Is it possible to copy a code module using VBA? | Excel Programming | |||
Merged Cells Autofit - code amendment | Excel Programming |