我有大约200个标准Excel 2003格式的Excel文件.
我需要将它们全部保存为Excel xml - 基本上与打开每个文件并选择另存为...然后选择另存为类型相同: XML Spreadsheet
你知道任何简单的自动化任务方法吗?
这是一个例程,它将转换具有.xls扩展名的单个目录中的所有文件.
这需要一个直截了当的方法.工作簿中的任何VBA代码都被删除,工作簿不会以.xlsm扩展名保存.不会显示任何不兼容性警告,而是自动接受更改.
Sub Convert_xls_Files() Dim strFile As String Dim strPath As String With Application .EnableEvents = False .DisplayAlerts = False .ScreenUpdating = False End With 'Turn off events, alerts & screen updating strPath = "C:\temp\excel\" strFile = Dir(strPath & "*.xls") 'Change the path as required Do While strFile <> "" Workbooks.Open (strPath & strFile) strFile = Mid(strFile, 1, Len(strFile) - 4) & ".xlsx" ActiveWorkbook.SaveAs Filename:=strPath & strFile, FileFormat:=xlOpenXMLWorkbook ActiveWorkbook.Close True strFile = Dir Loop 'Opens the Workbook, set the file name, save in new format and close workbook With Application .EnableEvents = True .DisplayAlerts = True .ScreenUpdating = True End With 'Turn on events, alerts & screen updating End Sub