hi all, i did want to let you know i found a slight bug in the code.
If i ran the code for the first time i would get an error that could only be caused by transferring vba code from "thisworkbook" section to a workbook that should not have this information transferred to it.
So i realized that i needed to be more specific in "exactly" specifying what workbooks are doing what. See code below.......note the code which does not specify the exact workbook references is commented out........
''copy thisworkbook code over to new workbook
'Set NewVBProj = NewWkb.Application.VBE.ActiveVBProject
'
'With wrkbk_macro.VBProject
'
' With .VBComponents("ThisWorkbook").CodeModule
' Code = .Lines(1, .CountOfLines)
' NewVBProj.VBComponents("ThisWorkbook").CodeModule.AddFromString Code
' End With
'
'End With
Dim sourceBook As Workbook
Dim destinationBook As Workbook
Dim codeFromSource As String
Set sourceBook = Workbooks(fl_macro)
Set destinationBook = NewWkb
With sourceBook.VBProject.VBComponents("ThisWorkbook").CodeModule
codeFromSource = .Lines(1, .CountOfLines)
End With
With destinationBook.VBProject.VBComponents("ThisWorkbook").CodeModule
.DeleteLines 1, .CountOfLines
.AddFromString codeFromSource
End With
Bookmarks