Hi,
I have written a workbook_beforeclose code that updates another workbook and then change a cell on the workbook with the time updated and lastly opens a msgbox telling the user telling if it has been successfully updated or an error occurred. Currently, the "save changes" dialog would open after the msgbox because one of the cells has been changed. I would like to have the "save changes" dialog appear before running the rest of the code. However, all I could find is how to open the "Save as" dialog which is not what I want.
So my code would look something like this:
I have written a workbook_beforeclose code that updates another workbook and then change a cell on the workbook with the time updated and lastly opens a msgbox telling the user telling if it has been successfully updated or an error occurred. Currently, the "save changes" dialog would open after the msgbox because one of the cells has been changed. I would like to have the "save changes" dialog appear before running the rest of the code. However, all I could find is how to open the "Save as" dialog which is not what I want.
So my code would look something like this:
Code:
Private Sub workbook_beforeclose(cancel As Boolean)
'open save dialog
If ActiveWorkbook.Saved = True Then
'run code
'show msgbox
activeworkbook.save
End If
activeworkbook.close
End Sub