This one has come up a few times lately.
PLEASE DO NOT REPLY TO THIS. ANY QUERIES SHOULD GO INTO A NEW MESSAGE.
PLEASE DO NOT REPLY TO THIS. ANY QUERIES SHOULD GO INTO A NEW MESSAGE.
Code:
'=====================================================
'Copying Modules Between Projects
'There isn't a single method to copy modules from one VBProject to another.
'Instead, we have to export the module from one project, and then import it into another.
'The following procedure will copy Module1 from Book2 to Book1.
'NB. Makes 2 files (.txt & .frx)
'- EXCEL VBA Editor - Menu - Tools/References/ ....
'- 'Microsoft Visual Basic for Applications Extensibility Library'
'=====================================================
Sub CopyOneModule()
Dim FName As String
With Workbooks("Book2")
FName = .Path & "\code.txt"
.VBProject.VBComponents("Module1").Export FName
End With
Workbooks("Book1").VBProject.VBComponents.import FName
End Sub