I want to save an Excel file to XLMS.
In office 2010 - 2016 this code works but in 2019 I get runtime error 1004.
I searched the internet for a solution.
I get the error on the SaveAs line.
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