打开excel 2007 excel文件并保存为VBA中的97-2003格式

我有一个奇怪的情况,我有一组excel文件,所有的扩展名为.xls。,在Excel 2007中我可以打开所有这些都很好。奇怪的是,我无法在Excel 2003中打开它们,在同一台机器上,2007年没有打开文件,并将其保存为“Excel 97-2003工作簿”。 在我从Excel 2007中将该文件保存为“Excel 97-2003工作簿”之前,当我在2003年打开Excel文件时,出现文件不是以可识别格式显示的错误。

所以我的问题是:如果我已经有在2007年打开的Excel文件,我已经打开文件的文件名称存储在一个variables,编程方式我怎样才能模仿上行到“办公button”的行动右键select“另存为”,然后select“Excel 97-2003 Workbook”? 我已经尝试了下面的东西,但它根本不保存文件:

ActiveWorkbook.SaveAs TempFilePath & TempFileName & ".xls", FileFormat:=56 

感谢您的任何帮助或指导!

这听起来像你应该尝试兼容包,但我不明白为什么你的VBA不工作。 我试了下面,它完美的工作:

 ThisWorkbook.SaveAs "C:\test" & ".xls", FileFormat:=56 

此页面: http ://www.rondebruin.nl/saveas.htm对我有帮助。 如果您要从2007年到2003年及更早的时间保存,则必须声明不同的文件types。

这是一个为我工作的解决scheme。 基本上,它再次打开相同的文件,并使用Excel 97-2003的兼容性模拟Officebutton中的“另存为”。 但是,它确实隐藏了任何警报,并指定Excel不检查生成popup窗口的兼容性,从而无法在批处理模式下进行静音工作。

 'before that, my code was using Workbooks.Add method, saving and then closing. 'just add the following after your last operation, once your file is closed where 'of course "resultFile" is the workbook to be saved, and resultFileName the path Application.DisplayAlerts = False Set resultFile = Workbooks.Open(resultFileName) resultFile.CheckCompatibility = False resultFile.SaveAs Filename:=resultFileName, FileFormat:=xlExcel8 resultFile.Close Application.DisplayAlerts = True 

我不清楚你是否只是想转换所有这些文件,或者如果你正在做一个需要这样做的应用程序。

如果是前者,看看这是否有帮助: http : //www.microsoft.com/downloads/details.aspx? familyid= 941b3470-3ae9-4aee- 8f43-c6bb74cd1466&displaylang= en

它允许您在早期版本的Office中打开Office 2007。

只是closures警报也适用。 Application.DisplayAlerts = False Workbooks.Add.SaveAs name,FileFormat:= 56 *根据需要对文件进行修改Activeworkbook.close SaveChanges:= true Application.DisplayAlerts = True

 'this script is created by me. But usable to vbscript ( vbs ). UTILIZAR EL ARCHIVO INICIAL.XLSX COMO COMODÍN PARA CREAR UN ARCHIVO DATOS.XLS. 'Creado por Juan Fernando Arango Trujillo Set app = CreateObject("Excel.Application") app.Visible = False app.DisplayAlerts = False Set fso = CreateObject("Scripting.FileSystemObject") Set wb = app.Workbooks.Open("C:\Users\Juan\Documents\Inicial.xlsx") wb.SaveAs "C:\Users\Juan\Documents\Datos.xls", -4143 wb.Close True app.Quit Set app = Nothing Set fso = Nothing 

'FIN DEL PROCESO DECREACIÓNDE DATOS.XLS