我有一个用于将活动工作表保存到新工作簿的宏。但是,它想要保存为.xlsx和我需要它另存为.xls
Private Sub SaveBarList_Click()
ActiveSheet.Copy
With ActiveSheet.UsedRange
.Copy
.PasteSpecial xlValues
.PasteSpecial xlFormats
End With
Dim strDir As String
'Show standard save as dialogue box
With Application.FileDialog(msoFileDialogSaveAs)
If .Show = -1 Then
strDir = .SelectedItems(1)
End If
End With
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=Application.GetSaveAsFilename, FileFormat:=-4143
Application.DisplayAlerts = True
ActiveWorkbook.Close
End Sub
发布于 2015-04-21 20:58:55
ActiveWorkbook.SaveAs method有一个允许不同文件格式的成员:XlFileFormat Enumeration。除了.xlsx之外,还有几种格式可供使用,包括.xls。
请注意,MSDN关于.SaveAs的文章(上面的第一个链接)说:“对于现有文件,默认格式是指定的最后一个文件格式;对于新文件,默认格式是所使用的Excel版本的格式。”
https://stackoverflow.com/questions/29753833
复制相似问题