Somehow you should know which name the document has. Which one is loaded at the moment. If it is a new Document, if you already saved the document.