Sub Test() If ActiveDocument.Dirty Then If MsgBox("Document is modified. Save?", vbOKCancel) = vbCancel Then Exit Sub ActiveDocument.Save End If ActiveDocument.Close End Sub