Hi all,
I'm trying to write a VBA macro that opens all .txt files in a folder and saves them as .xls with the same name. I've found some code online that has some of the same functionality but they use Application.Filesearch which is no longer available on Excel 2010.
I found an example using the Dir function but am having trouble getting it to work.
Thanks for any help you can offer.
Sub LoopAllFiles()
sPath = "S:\Test loop macro\files"
sDir = Dir$(sPath & "*.txt", vbNormal)
Do Until LenB(sDir) = 0
Set oWB = Workbooks.Open(sPath & sDir)
ActiveWorkbook.SaveAs , FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
oWB.Close
sDir = Dir$
Loop
End Sub
Bookmarks