none
Word Office Js Update a document Word, Compressed and check RRS feed

  • Question

  • I’m working on a addin, i did tutos; So... I can add texts, paragraphs and clear…

    I am trying to get all the document with getFileAsync.

    (Example found on the doc) First, with Office.FileType.Text: my raw data was correct, I failed my encoding, it was not proper but the result.value was what I wanted.

    Later, my aim is to get a file from a service, .docx or zip, update the document in my Add-in and send it back. For the moment, I do not have a “back”, I am working on document open by myself.
    So, I do not have any service where I could send or save my file. I am using Office.FileType.Compressed to get the whole document (after update), how can I check if my document is still correct (data and Style)? I know with the FileType.Text way, it’s working (I got the correct value), but I would like to keep the edition (color, size...). Do I have a method in the Office Js library (or angular5 without new module) to open/display the result of my getFileAsync directly in my Word Document? (I am a beginner for both of them).

    In the future, what is the correct way to load and open the document get by my services in Word (office Js)?

    Thanks (Sorry for my english, it's not my native langage)

    Tuesday, November 20, 2018 5:41 PM

All replies

  • Hi ByssyB,

    >> Later, my aim is to get a file from a service, .docx or zip, update the document in my Add-in and send it back.

    According to your description, you can try the code as below:

    // Get all of the content from a PowerPoint or Word document in 100-KB chunks of text.
    function sendFile() {
        Office.context.document.getFileAsync("compressed",
            { sliceSize: 100000 },
            function (result) {
    
                if (result.status == Office.AsyncResultStatus.Succeeded) {
    
                    // Get the File object from the result.
                    var myFile = result.value;
                    var state = {
                        file: myFile,
                        counter: 0,
                        sliceCount: myFile.sliceCount
                    };
    
                    updateStatus("Getting file of " + myFile.size + " bytes");
                    getSlice(state);
                }
                else {
                    updateStatus(result.status);
                }
            });
    }

    For more information, please review the following link:

    Get the whole document from an add-in

    >> I am trying to get all the document with getFileAsync.

    More information about getFileAsync for your reference:

    getFileAsync(fileType, options, callback)

    Hopefully it helps you.

    Best Regards,

    Yuki


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Wednesday, November 21, 2018 6:19 AM
    Moderator
  • This question has received an answer from the MSFT team for Office JS APIs on Stack Overflow

    https://stackoverflow.com/questions/53397318/word-office-js-update-a-document-word-compressed-and-check


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    Wednesday, November 21, 2018 11:16 AM
    Moderator