Close the active document with save option

Hi,

Good morning to all,

I need a code for close the active document with save option. Whenever i am going to close the document, i need to ask "Do you want to save or not". If i click yes means the file should be saved and one more thing if the file name already exists means it display the message like "File already exists" message.

SolidworksApi macros