HI Guys!

I'm running into some problems with this macro I found online. I think I adjusted everything to suit my needs, which is to copy module2 with the macro's it contains into a new workbook. Somehow this code is not doing anything though. No code is transferred to the example file.

Hope you can help out!

Sub CopyModule(SourceWB As Workbook, strModuleName As String, TargetWB As Workbook)
' copies a module from one workbook to another
' example:
'CopyModule Workbooks("example1.xlsm"), "Module2", _
 '   Workbooks("example2.xlsm")
Dim strFolder As String, strTempFile As String
    strFolder = SourceWB.Path
    If Len(strFolder) = 0 Then strFolder = CurDir
    strFolder = strFolder & "\"
    strTempFile = strFolder & "~tmpexport.bas"
    On Error Resume Next
    SourceWB.VBProject.VBComponents(strModuleName).Export strTempFile
    TargetWB.VBProject.VBComponents.Import strTempFile
    Kill strTempFile
    On Error GoTo 0
End Sub
Sub test()

Call CopyModule(Workbooks("Example1.xlsm"), "Module2", Workbooks("Example2.xlsm"))
End Sub