LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
michaelberrier
 
Posts: n/a
Default Importing modules from a folder

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.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying all files in a folder to new folder michaelberrier Excel Discussion (Misc queries) 2 June 20th 06 05:35 AM
can excel links be somehow relative to folder structure? Paul134 Excel Discussion (Misc queries) 0 March 2nd 06 03:22 PM
Need code to save file to new folder, erase from old folder Ron M. Excel Discussion (Misc queries) 1 February 24th 06 06:02 PM
Password protection of Folder Ron Coderre Excel Discussion (Misc queries) 0 February 3rd 06 05:48 PM
What is folder OLK7 and where can I find it? HELP! Excel Discussion (Misc queries) 1 April 1st 05 05:35 AM


All times are GMT +1. The time now is 10:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"