I need to write a code that writes another code but not into a module but rather into ThisWorkbook so that the code is executed on open, Private Sub Workbook_Open(). I have a code that writes a code into a module:
Dim VBP As VBProject
Dim VBC As VBComponent
Dim VBMod As CodeModule
Set VBP = ActiveWorkbook.VBProject
Set VBC = VBP.VBComponents.Add(vbext_ct_StdModule)
VBC.Name = "resultsPrint"
Set VBMod = VBC.CodeModule
....... lines to be written
End Sub
So this code writes the code (...lines to be written) into a module. I am assuming I just need to change VBC.CodeModule into something that is not a module but I don't know what that is. Hope this makes sense...
Thanks!
Layla
Dim VBP As VBProject
Dim VBC As VBComponent
Dim VBMod As CodeModule
Set VBP = ActiveWorkbook.VBProject
Set VBC = VBP.VBComponents.Add(vbext_ct_StdModule)
VBC.Name = "resultsPrint"
Set VBMod = VBC.CodeModule
....... lines to be written
End Sub
So this code writes the code (...lines to be written) into a module. I am assuming I just need to change VBC.CodeModule into something that is not a module but I don't know what that is. Hope this makes sense...
Thanks!
Layla