title: Is there a way to delete a section break in Word-js?
body: <p>I am writing a Word add-in using office-js that generates an index. It uses the following code to create a section break at the end of the document, and then writes the index there:</p>
  
  <pre><code>function WriteIndex() {
     Word.run(function (context) {
     //
     var html = GenerateIndex(); // generate the index as an html string
     //
     if (html.length &gt; 0) {
        var body = context.document.body;
        body.insertBreak(Word.BreakType.sectionNext, Word.InsertLocation.end);
        body.select("End"); // put it at the end
        return context.sync().then(function () {
           body = context.document.body;
           body.select("End"); // put it at the end
           body.insertHtml(html, Word.InsertLocation.end);
           return context.sync();
        });
      }).catch(handleError);
  } 
  </code></pre>
  
  <p>So far, so good -- it works just as I want it to. But now I want to be able to re-run the function and delete the index that was there before regenerating and rewriting it.</p>
  
  <p>I think I can get the contents of the index into a range and delete it. But I can't find anywhere in the API where you can delete a section break. I found some code at this <a href="https://stackoverflow.com/questions/46078169/officejs-delete-and-rearrange-sections-in-a-word-document">link</a> that iterates through the document section collection and gathers the contents of <strong>all</strong> the sections, then replaces the entire contents of the document with only the sections wanted. But this approach feels risky and convoluted to me. Another approach might be to essentially navigate to the end of the document and perform a backspace operation, since that's how you delete a section break using the Word UI, but I can't find anything in the API documentation to do that either.</p>
  
  <p>Is it really the case that the API allows you to create section breaks but doesn't allow you to delete them? Has anyone done anything like this before? Is there a better approach?</p>
  
  <p>Thanks very much.</p>