none
Office Add-ins , How can I delete entire document content in Office Word ? JavaScript RRS feed

  • Question

  • Hello,

    I wan't to delete(clear) with a button(or some event) from JavaScript , from my task panel app , all the context of the document(pages) to be a empty document.

    Thank you,

    Sami

    Thursday, August 6, 2015 9:07 PM

Answers

  • Hi, see this similar question:

    https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/926e535c-9974-4844-a6ce-c1154cfbd0a0/clear-whole-document-using-javascript-office-api?forum=appsforoffice

    You cannot easily do this. The JavaScript API allows you to bind to certain named elements, or to the current selection. It's, as far as I know, to select the entire document to clear it.


    Please remember to mark your question as answered & Vote helpful
    Check my blog or follow me on Twitter

    Thursday, August 6, 2015 10:26 PM
  • Hi Samuel

    Currently, the JavaScript APIs for task pane apps does not enable you to address/select the entire Word document UNLESS the user selects it (Ctrl+A, for example). In that case, you can work on the Selection. But that's all that can be done with Word 2013.

    If you need this kind of thing and cannot program a COM Add-in (IDTExtensibility2 or VSTO) then watch for Office 2016 and what that brings for Office Developers...


    Cindy Meister, VSTO/Word MVP, my blog

    Sunday, August 16, 2015 4:18 PM

All replies

  • Hi, see this similar question:

    https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/926e535c-9974-4844-a6ce-c1154cfbd0a0/clear-whole-document-using-javascript-office-api?forum=appsforoffice

    You cannot easily do this. The JavaScript API allows you to bind to certain named elements, or to the current selection. It's, as far as I know, to select the entire document to clear it.


    Please remember to mark your question as answered & Vote helpful
    Check my blog or follow me on Twitter

    Thursday, August 6, 2015 10:26 PM
  • Hello,

    The solution in the https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/926e535c-9974-4844-a6ce-c1154cfbd0a0/clear-whole-document-using-javascript-office-api?forum=appsforoffice      

    is to build a office add-in. I can't not do that, but there is a way to select all the document from the javaScript?

    Friday, August 7, 2015 11:16 AM
  • Hello,

    The solution in the https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/926e535c-9974-4844-a6ce-c1154cfbd0a0/clear-whole-document-using-javascript-office-api?forum=appsforoffice      

    is to build a office add-in. I can't not do that, but there is a way to select all the document from the javaScript?

    see my earlier response, as far as I know you cannot select the entire document.

    Please remember to mark your question as answered & Vote helpful
    Check my blog or follow me on Twitter

    Monday, August 10, 2015 1:08 AM
  • Hi Samuel

    Currently, the JavaScript APIs for task pane apps does not enable you to address/select the entire Word document UNLESS the user selects it (Ctrl+A, for example). In that case, you can work on the Selection. But that's all that can be done with Word 2013.

    If you need this kind of thing and cannot program a COM Add-in (IDTExtensibility2 or VSTO) then watch for Office 2016 and what that brings for Office Developers...


    Cindy Meister, VSTO/Word MVP, my blog

    Sunday, August 16, 2015 4:18 PM
  • Hi Sami,

    Were you able to achieve what you were trying?

    Thanks,

    Jay

    Friday, July 8, 2016 6:19 PM