DocumentCreated does not save twice

DocumentCreated does not save twice



 Apr 28 2022
2 Comments (2 New)

Hello, when creating a new document from the office-js API with application.createDocument, the newly created document may be saved by using the save method. If you now want to save the document twice, the changes which are made after the first save are not saved anymore. The changes are shown in the document, but the saved document on the disc still has the content from the initial save. If you are wonding, why should one save changes twice, a little explanation on that: The API does not provide a "save as" method (which is very suprising, because its a quite important feature, same as an "open from" function). If you want to save a document with an at least somehow suitable name, you need to use Word default behaviour. Therefore we create a paragraph with the Filename wich is insereted at the beginning of the document, then save the document (Word takes the content of the paragraph and use it as filename) and afterwards, this paragraph must be removed again and the document must be saved again. Result is as explained, the created document can be shown with open and it shows the correct content, but the one which is save on disc still contains the paragraph with the filename.


Occasional Visitor

This is even worst, Word takes the first word of the paragraph, it stops at any special character and does not support any path so this is not possible to control the save functionality.

For me, using DocCreated is better because processing is done in memory (avoid UI slow updates) but then we need the save functionality on DocCreated (just logged a request for it). 

Established Member

@lelsteph_Syes its a totally nasty "workaround" with the paragraph. As I have pointed out, I can't understand why this feature is not part of the API and in my opinion this is a show stopper for many use cases. On the other side, I also do not understand why the existing ideas regarding this topic are not upvoted, so that the developer are aware of it. Therefore please upvote the existing issues regarding the save as functionality, like this:

I dont know if this helps, but at least they promise to do so...