Junior6202
Programmer
Hi all,
I found a script that I had modified a bit. The purpose of this script is to convert ".csv" files to Excel. The code works, but there are 600 csv files in the folder, I know that I have to set a loop to go through each file and convert it. I have the basic idea of what a loop does but I'm new to programming and not sure how to accomplish it. any help will be appreciated. Here is my code.
Const xlDelimited = 1
Const xlTextQualifierDoubleQuote = 1
Const xlOpenXMLWorkbook = 51
MyDate = Replace(Date, "/", "-")
Set xl = CreateObject("Excel.Application")
xl.Workbooks.OpenText "P:\shipping\test\*.CSV", , , xlDelimited _
, xlTextQualifierDoubleQuote, True, False, False, True, False, False, _
, Array(Array(1,2), Array(2,2), Array(3,2), Array(4,1), Array(5,2) _
, Array(6,1), Array(7,1), Array(8,1), Array(9,1), Array(10,1), Array(11,1))
Set wb = xl.ActiveWorkbook
wb.SaveAs "P:\shipping\test1\QVD_UPS" & MyDate & ".xlsx", xlOpenXMLWorkbook, , , , False
wb.Close
xl.Quit
I found a script that I had modified a bit. The purpose of this script is to convert ".csv" files to Excel. The code works, but there are 600 csv files in the folder, I know that I have to set a loop to go through each file and convert it. I have the basic idea of what a loop does but I'm new to programming and not sure how to accomplish it. any help will be appreciated. Here is my code.
Const xlDelimited = 1
Const xlTextQualifierDoubleQuote = 1
Const xlOpenXMLWorkbook = 51
MyDate = Replace(Date, "/", "-")
Set xl = CreateObject("Excel.Application")
xl.Workbooks.OpenText "P:\shipping\test\*.CSV", , , xlDelimited _
, xlTextQualifierDoubleQuote, True, False, False, True, False, False, _
, Array(Array(1,2), Array(2,2), Array(3,2), Array(4,1), Array(5,2) _
, Array(6,1), Array(7,1), Array(8,1), Array(9,1), Array(10,1), Array(11,1))
Set wb = xl.ActiveWorkbook
wb.SaveAs "P:\shipping\test1\QVD_UPS" & MyDate & ".xlsx", xlOpenXMLWorkbook, , , , False
wb.Close
xl.Quit