VBA保存Excel文件
Private SubCommandButton1_Click()
Dim xFileName AsString
Application.DisplayAlerts= False
xFileName =Application.GetSaveAsFilename(ActiveWorkbook.Name, "Excel Workbook(*.xlsx),*.xlsx,Excel Macro-Enabled Workbook (*.xlsm),*.xlsm")
If (xFileName <>"") Or (xFileName <> "False") Then
If Right(xFileName, 4) = "xlsm"Then
ActiveWorkbook.SaveAs Filename:=xFileName,FileFormat:=xlOpenXMLWorkbookMacroEnabled ‘保存为启用宏表
Else
ActiveWorkbook.SaveAs Filename:=xFileName,FileFormat:=xlOpenXMLWorkbook ‘保存为非宏表
End If
End If
Application.DisplayAlerts= True
End Sub

155

被折叠的 条评论
为什么被折叠?



