Importing modules from a folder

M

michaelberrier

Chip Pearson's website has great code for copying modules between
projects, but can anyone tell me how to tweak the code so that I can
copy modules from a folder or directory. Here is the code for the
unenlightened:

Sub CopyAllModules()

Dim FName As String
Dim VBComp As VBIDE.VBComponent

With Workbooks("Book2")
FName = .Path & "\code.txt"
If Dir(FName) <> "" Then
Kill FName
End If
For Each VBComp In .VBProject.VBComponents
If VBComp.Type <> vbext_ct_Document Then
VBComp.Export FName
Workbooks("book1").VBProject.VBComponents.Import FName
Kill FName
End If
Next VBComp
End With

End Sub

I'm guessing I need to change the first line, "With Workbooks...", but
I don't know the syntax to fix it.

Thanks to all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top