How can I open all excel workbooks in a folder which starts with "BFR"...
Something like this:
For each wb in folder("X")
if filename = "BFR*" then
end if
Loop
how do I write this correct?
Thanks for the help
How can I open all excel workbooks in a folder which starts with "BFR"...
Something like this:
For each wb in folder("X")
if filename = "BFR*" then
end if
Loop
how do I write this correct?
Thanks for the help
Maybe
Sub ProcessFiles()
Dim FSO As Object
Dim i As Long
Dim sFolder As String
Dim fldr As Object
Dim Folder As Object
Dim file As Object
Dim Files As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
sFolder = "C:\myTest\myTest"
'sFolder = "c:\my documents\excel\test"
If sFolder <> "" Then
Set Folder = FSO.GetFolder(sFolder)
Set Files = Folder.Files
For Each file In Files
If Left(file.Name,3) = "BFR" Then
Workbooks.Open Filename:=file.Path
With ActiveWorkbook
.SaveAs Left(.FullName, Len(.FullName) - 4), _
FileFormat:=xlTextMac
.Close savechanges:=False
End With
End If
Next file
End If ' sFolder <> ""
End Sub
--
HTH
Bob Phillips
(remove nothere from the email address if mailing direct)
"Ctech" <[email protected]> wrote in
message news:[email protected]...
>
> How can I open all excel workbooks in a folder which starts with
> "BFR"...
>
> Something like this:
>
>
> For each wb in folder("X")
> if filename = "BFR*" then
> end if
> Loop
>
>
> how do I write this correct?
>
>
> Thanks for the help
>
>
> --
> Ctech
>
>
> ------------------------------------------------------------------------
> Ctech's Profile:
http://www.excelforum.com/member.php...o&userid=27745
> View this thread: http://www.excelforum.com/showthread...hreadid=505288
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks