Good Evening,
I have the following code which I want to be able to loop through all the files in a folder that will change daily.
The code itself basically opens up a data delimited file, converts to excel and then deletes the original file.
At the moment I can do it one by one and it works great but I'm hoping that i could possibly just select the first file in the folder, press start and it works its way through all of the files until only the xlsx files remain.
below is my code,
Thank you for any help.
Tom
I have the following code which I want to be able to loop through all the files in a folder that will change daily.
The code itself basically opens up a data delimited file, converts to excel and then deletes the original file.
At the moment I can do it one by one and it works great but I'm hoping that i could possibly just select the first file in the folder, press start and it works its way through all of the files until only the xlsx files remain.
below is my code,
Code:
Sub Master()
Call D140
Call Save_Delete_Original
End Sub
Private Sub D140()
MsgBox ("Please Select The D140 Report ")
Path = Application.GetOpenFilename
If Path = "False" Then
MsgBox ("User Cancelled!")
Else
Workbooks.Open Filename:=Path
HRDATA_file1 = ActiveWorkbook.Name
End If
End Sub
Private Sub Save_Delete_Original()
Dim fn As String
fn = Application.ActiveWorkbook.FullName
fn = Replace(fn, "xls", "xlsx")
'save as xlsx
ActiveWorkbook.SaveAs fn, FileFormat:=51
'delete .xls file
fn = Replace(fn, "xlsx", "xls")
Kill fn
'saves and closes workbook
ActiveWorkbook.Close True
End Sub
Thank you for any help.
Tom