Below is a Macro that I have taken and "attempted" to modify to what exactly as I want. I feel that I am very close and am just missing one or two things , however I am not too familiar with macros or VB for that matter. My end goal with this macro is to go through the directory listed above ( G:/Proj) and print only the excel files in the sub folders named "Summary Log". This macro right now however goes through and prints every single excel file in every single sub folder. Any ideas on how I can trim the results just to print the ones under the File names "Summary Log"?
Thanks
Thanks
Code:
[/FONT][/COLOR]Sub LoopFolders()
Dim strFolder As String
Dim strSubFolder As String
Dim strFile As String
Dim colSubFolders As New Collection
Dim varItem As Variant
Dim wbk As Workbook
' Parent folder including trailing backslash
strFolder = "G:/Proj/"
' Loop through the subfolders and fill Collection object
strSubFolder = Dir(strFolder & "*", vbDirectory)
Do While Not strSubFolder = ""
Select Case strSubFolder
Case ".", ".."
' Current folder or parent folder - ignore
Case Else
' Add to collection
colSubFolders.Add Item:=strSubFolder, Key:=strSubFolder
End Select
' On to the next one
strSubFolder = Dir
Loop
' Loop through the collection
For Each varItem In colSubFolders
' Loop through Excel workbooks in subfolder
strFile = Dir(strFolder & varItem & "\*.xls*")
Do While strFile <> ""
' Open workbook
Set wbk = Workbooks.Open(Filename:=strFolder & _
varItem & "\" & strFile, AddToMRU:=False)
' Do something with the workbook
ActiveSheet.PrintOut
' Close it
wbk.Close SaveChanges:=False
strFile = Dir
Loop
Next varItem
End Sub
[COLOR=#000000][FONT=Verdana]