如何另存为xlsx文件?

问题描述 投票:5回答:1

我的SaveFile子保存文件,但是当我再次尝试打开它时,Excel无法将其识别为Excel文件。

如果我从桌面上右键单击文件并检查属性,则文件的类型为“文件”。我已经阅读了格式,但无法将此文件另存为xlsx格式。我能够使启用宏的excel文件正常工作,但这不是我想要的。

Sub SaveFile()

    MsgBox ("You will now be prompted to save your file") 'Notifies User 
    savename = Application.GetSaveAsFilename()  'Gets directory/name
    ActiveWorkbook.SaveAs Filename:=savename, FileFormat:=51 'Something is wrong 

End Sub

这里是“无格式”文件的图片enter image description here

excel vba save-as
1个回答
6
投票

保存文件时,应使用扩展名保存它:

Sub SaveFile()

    savename = Application.GetSaveAsFilename(fileFilter:="Exel Files (*.xlsx), *.xlsx")) 
    ActiveWorkbook.SaveAs Filename:=savename, FileFormat:=51 

End Sub
© www.soinside.com 2019 - 2024. All rights reserved.