如何在vbs中保存xlsx文件? [英] How to save xlsx file in vbs?
问题描述
我打开了一个 csv 文件,需要将它保存为 xlsx
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"
全部保存,但文件已损坏,我无法打开它.当我更改为 .xls
时,它可以工作,但无法正确读取数据.我需要 xlsx
.我怎样才能保存它.那么,如何将 .csv
转换为 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
?
推荐答案
为此,您必须使用 Excel 2003,对吗?
You must be using Excel 2003 for this, is that right?
如果是这样,根据这个:http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/f305f427-af64-4d62-85b8-e0395161eadf/
If so, according to this: http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/f305f427-af64-4d62-85b8-e0395161eadf/
你需要使用51的FileFormat:
You need to use the FileFormat of 51:
试试这个
objWb.saveas "C:\Users\xxx\test.xlsx",51
这篇关于如何在vbs中保存xlsx文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!