str_savefilename_xls=gs_exportpath + "转换_" + dw_1.getitemstring(filerowi,"filename") + ".xls"
ObjExcel.activeworkbook.saveas(str_savefilename_xls,18)
ObjExcel.activeworkbook.saveas(str_savefilename_xls,18)
添加一个参数即可。
中文的msdn上写的xlAddIn-18对应的是2007,我测试了一下,发现中文msdn上是错误的。如果想保存成xlsx,请使用xlWorkbookDefault-51,并且后缀改为xlsx。
API [ https://msdn.microsoft.com/en-us/vba/excel-vba/articles/workbook-saveas-method-excel ]
SaveAs( FileName , FileFormat , Password , WriteResPassword , ReadOnlyRecommended , CreateBackup , AccessMode , ConflictResolution , AddToMru , TextCodepage , TextVisualLayout , Local )
FileFormat [ https://msdn.microsoft.com/en-us/vba/excel-vba/articles/xlfileformat-enumeration-excel ]
Name | Value | Description |
---|---|---|
xlAddIn | 18 | Microsoft Excel 97-2003 Add-In |
xlAddIn8 | 18 | Microsoft Excel 97-2003 Add-In |
xlCSV | 6 | CSV |
xlCSVMac | 22 | Macintosh CSV |
xlCSVMSDOS | 24 | MSDOS CSV |
xlCSVWindows | 23 | Windows CSV |
xlCurrentPlatformText | -4158 | Current Platform Text |
xlDBF2 | 7 | DBF2 |
xlDBF3 | 8 | DBF3 |
xlDBF4 | 11 | DBF4 |
xlDIF | 9 | DIF |
xlExcel12 | 50 | Excel12 |
xlExcel2 | 16 | Excel2 |
xlExcel2FarEast | 27 | Excel2 FarEast |
xlExcel3 | 29 | Excel3 |
xlExcel4 | 33 | Excel4 |
xlExcel4Workbook | 35 | Excel4 Workbook |
xlExcel5 | 39 | Excel5 |
xlExcel7 | 39 | Excel7 |
xlExcel8 | 56 | Excel8 |
xlExcel9795 | 43 | Excel9795 |
xlHtml | 44 | HTML format |
xlIntlAddIn | 26 | International Add-In |
xlIntlMacro | 25 | International Macro |
xlOpenDocumentSpreadsheet | 60 | OpenDocument Spreadsheet |
xlOpenXMLAddIn | 55 | Open XML Add-In |
xlOpenXMLStrictWorkbook | 61 (&;H3D) | Strict Open XML file |
xlOpenXMLTemplate | 54 | Open XML Template |
xlOpenXMLTemplateMacroEnabled | 53 | Open XML Template Macro Enabled |
xlOpenXMLWorkbook | 51 | Open XML Workbook |
xlOpenXMLWorkbookMacroEnabled | 52 | Open XML Workbook Macro Enabled |
xlSYLK | 2 | SYLK |
xlTemplate | 17 | Template |
xlTemplate8 | 17 | Template 8 |
xlTextMac | 19 | Macintosh Text |
xlTextMSDOS | 21 | MSDOS Text |
xlTextPrinter | 36 | Printer Text |
xlTextWindows | 20 | Windows Text |
xlUnicodeText | 42 | Unicode Text |
xlWebArchive | 45 | Web Archive |
xlWJ2WD1 | 14 | WJ2WD1 |
xlWJ3 | 40 | WJ3 |
xlWJ3FJ3 | 41 | WJ3FJ3 |
xlWK1 | 5 | WK1 |
xlWK1ALL | 31 | WK1ALL |
xlWK1FMT | 30 | WK1FMT |
xlWK3 | 15 | WK3 |
xlWK3FM3 | 32 | WK3FM3 |
xlWK4 | 38 | WK4 |
xlWKS | 4 | Worksheet |
xlWorkbookDefault | 51 | Workbook default |
xlWorkbookNormal | -4143 | Workbook normal |
xlWorks2FarEast | 28 | Works2 FarEast |
xlWQ1 | 34 | WQ1 |
xlXMLSpreadsheet | 46 | XML Spreadsheet |