0
votes

I open a csv file and need to save it as xlsx

set objExcel = createObject("Excel.Application")
objExcel.visible = True 
set objWb = objExcel.Workbooks.Open("C:\Users\xxx\test.csv") 
msgbox "make sure data is ok" 'Here I can see all data was read properly, now I need to save it 
objWb.saveas "C:\Users\xxx\test.xlsx" 

All saves, but the file is corrupted, I cannot open it. When I change to .xls then it works but the data is not read correctly. I need xlsx . How can I save it. So, how to convert .csv to xlsx ?

1

1 Answers

3
votes

You must be using Excel 2003 for this, is that right?

If so, according to this: http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/f305f427-af64-4d62-85b8-e0395161eadf/

You need to use the FileFormat of 51:

try this

objWb.saveas "C:\Users\xxx\test.xlsx",51