【发布时间】:2016-11-30 08:31:56
【问题描述】:
当我想在桌面上的文件夹中保存 Excel 工作簿时,我使用 vba 获得了 Runtime error 1004 document not saved。以下是我的代码的详细信息:
Private Sub Save_Click()
'Popup the Window "Save As"
Application.DisplayAlerts = False
MsgBox "Do not change the default file name proposed on the next step please !"
Dim fName As Variant
Dim DName As String ' Variable storing name of excel workbook which has to be saved
DName = UserForm.CustomerApplication.Value & " - " & UserForm.L2GType.Value
& " - " & UserForm.Title.Value & " - " & UserForm.Country.Value & "(" &
Year(Date) & ")"
fName = Application.GetSaveAsFilename(InitialFileName:=DName, _
FileFilter:="Excel Files (*.XLSX), *.XLSX", Title:="Save As")
If fName = False Then
Exit Sub
ActiveWorkbook.SaveAs filename:=fName, FileFormat:=51
ActiveWorkbook.Close
End Sub
【问题讨论】:
-
你们能帮我吗,因为我在这部分代码中遇到了错误 ActiveWorkbook.SaveAs 文件名:=fName,文件格式:=51
-
您是否测试过以下提供的任何解决方案?任何反馈都会很好......