4

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

所以我的问题是:如果我已经在 2007 年打开了 excel 文件,并且我已经将打开文件的文件名存储在一个变量中,那么我如何以编程方式模仿上层的“办公按钮”的动作右键并选择“另存为”,然后选择“Excel 97-2003 工作簿”?我已经尝试过类似下面的方法,但它根本不保存文件:

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

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

4

6 回答 6

7

听起来您应该尝试兼容包,但我不明白为什么您的 vba 不起作用。我尝试了以下方法,效果很好:

ThisWorkbook.SaveAs "C:\test" & ".xls", FileFormat:=56
于 2010-01-26T21:49:34.783 回答
1

这是一个对我有用的解决方案。基本上,它会再次打开同一个文件并模拟 Office 按钮中的“另存为”,与 Excel 97-2003 的兼容性。但是,它确实隐藏了任何警报,并指定 Excel 不检查兼容性,这会生成一个弹出窗口,阻止您在批处理模式下静默工作。

'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
于 2012-04-26T09:40:01.037 回答
1

此页面:http : //www.rondebruin.nl/saveas.htm 对我很有帮助。如果您从 2007 年保存到 2003 年或更早的版本,则必须声明不同的文件类型。

于 2010-01-27T17:07:42.203 回答
0

我不清楚您是否只是想转换所有这些文件,或者您是否正在开发需要这样做的应用程序。

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

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

于 2010-01-26T21:22:18.933 回答
0

只需关闭警报也可以。Application.DisplayAlerts = False Workbooks.Add.SaveAs name, FileFormat:=56 * 如有必要,对文件进行修改 Activeworkbook.close SaveChanges:=true Application.DisplayAlerts = True

于 2013-06-20T03:50:18.247 回答
0
'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 DE CREACIÓN DE DATOS.XLS

于 2016-01-06T13:54:23.480 回答