我想将 Excel 文件保存到 XLMS。
在 office 2010 - 2016 中,此代码有效,但在 2019 年我收到运行时错误 1004。
我在互联网上搜索了解决方案。
我在 SaveAs 行收到错误。
Dim Wb As Workbook
Dim NewFileName As String
Dim NewFileFilter As String
Dim myTitle As String
Dim FileSaveName As Variant
Dim NewFileFormat As Long
Set Wb = ThisWorkbook
NewFileName = "Test.xlsm"
NewFileFilter = "Excel Macro-Enabled workbook (*.xlsm), *.xlsm"
NewFileFormat = 52
myTitle = "Navigate to the required folder"
FileSaveName = Application.GetSaveAsFilename _
(InitialFileName:=NewFileName, _
filefilter:=NewFileFilter, _
Title:=myTitle)
If Not FileSaveName = False Then
Wb.SaveAs FileName:=FileSaveName, _
FileFormat:=NewFileFormat
'Call PDF_PRINT
Else
'MsgBox "File NOT Saved. User cancelled the Save."
X = MsgBox("ExcelFile NOT Saved.User cancelled the Save." & vbCrLf & _
"Click CANCEL to abort pdf-save function as well." & vbCrLf & _
"Or click OK to proceed with the pdf-saving function.", vbOKCancel, _
"EXCEL SAVE FUNCTION")
If X = vbOK Then PDF_PRINT Else Exit Sub
End If