Hi
Following on from this thread, is there a way you can
Import all 'bas' files in a network folder to a new excel spreadsheet.
If you have say 30 modules in one spreadsheet and you want to export them all to another spreadsheet,
I have the code below, and I get an error in the line:
fn.FoundFiles.Import _
Filename:="L:" & "" & "book2" & ".xls"
Sub ImportAllVBA()
'Need to change code
Dim fs As FileSearch, ws As Worksheet, i, j As Long
Dim f, mySubFolders, aFolder
'Dim VBComp As VBIDE.VBComponent
Set fs = Application.FileSearch
With fs
.SearchSubFolders = False ' set to true if you want sub-folders included
' .FileType = msoFileTypeAllFiles 'This lists all files
fn = InputBox("Which directory do you want files from?", , "L:\VBAcode")
.LookIn = fn
'.LookIn = "L:" 'modify this to where you want to search
If .Execute > 0 Then
'Set ws = Worksheets.Add
Workbooks("book2.xls").Activate
For i = 1 To .FoundFiles.Count
fn.FoundFiles.Import _
Filename:="L:" & "\" & "book2" & ".xls"
Next
End If
End With
End Sub
Following on from this thread, is there a way you can
Import all 'bas' files in a network folder to a new excel spreadsheet.
If you have say 30 modules in one spreadsheet and you want to export them all to another spreadsheet,
I have the code below, and I get an error in the line:
fn.FoundFiles.Import _
Filename:="L:" & "" & "book2" & ".xls"
Sub ImportAllVBA()
'Need to change code
Dim fs As FileSearch, ws As Worksheet, i, j As Long
Dim f, mySubFolders, aFolder
'Dim VBComp As VBIDE.VBComponent
Set fs = Application.FileSearch
With fs
.SearchSubFolders = False ' set to true if you want sub-folders included
' .FileType = msoFileTypeAllFiles 'This lists all files
fn = InputBox("Which directory do you want files from?", , "L:\VBAcode")
.LookIn = fn
'.LookIn = "L:" 'modify this to where you want to search
If .Execute > 0 Then
'Set ws = Worksheets.Add
Workbooks("book2.xls").Activate
For i = 1 To .FoundFiles.Count
fn.FoundFiles.Import _
Filename:="L:" & "\" & "book2" & ".xls"
Next
End If
End With
End Sub