First off, please wrap your code in code tags. Also please, for the love of god, format your code better. Seriously.
Try the code below.
Public CloseMode As Boolean
Sub Save_Close()
Dim Passwrd As String
Dim xx As Variant
Dim sFileFormat
Passwrd = "PASSWORD"
xx = MsgBox("Do you want to close the file?", vbYesNo)
If xx <> vbYes ThenCancel = True
Else
'Why did you leave these comments in?'fileformats
' xls = -4143 < 2007
' xlsm = 52 2007 >
With Application
sFileFormat = IIf(.Version < 12, -4143, 52)
End With
With ThisWorkbook
.SaveAs Filename:=.FullName, _
FileFormat:=sFileFormat, _
ReadOnlyRecommended:=False, _
.Close '<--- This will close the workbook, not the application
End With
'This is where you told the application (not the workbook) to close
'CloseMode = False
'With Application '<-- See, the word "application" is a clue as to what you are changing
'End With
End If
End Sub
Bookmarks