title: Cannot insert Table at binding
body: <p>I am trying to insert a Table into a RichText Content Control (I found documentation stating bindings only work with RichText controls) but it fails with:</p>
  
  <blockquote>
    <p>The type of the specified data object is not compatible with the current selection.</p>
  </blockquote>
  
  <p>I am able to insert HTML into the binding with coercionType "html".
  I am also able to insert a table at the selection cursor but that seriously degrades the document automation experience if someone has to click where they want the table.
  I can also insert the Table by programmatically navigating to the binding then doing the insert but this seems a bit hacky.
  Is my syntax just wrong or is it not possible to insert a Table at a binding without the current selection being within it?</p>
  
  <p>CSHTML:</p>
  
  <pre><code>@{
      ViewBag.Title = "Home Page";
  }
  
  &lt;div class="row"&gt;
      &lt;button onclick="return addRowsWithoutSelection();"&gt; Insert Table At Binding &lt;/button&gt;&lt;br /&gt;
      &lt;button onclick="return navigateToBinding();"&gt; Navigate then insert table &lt;/button&gt;&lt;br /&gt;
      &lt;button onclick="return addRowsAtSelection();"&gt; Insert Table At Selection &lt;/button&gt;&lt;br /&gt;
      &lt;button onclick="return addHTML();"&gt; Insert HTML &lt;/button&gt;&lt;br /&gt;
  &lt;/div&gt;
      Results: &lt;div id="results"&gt;&lt;/div&gt;
  &lt;div id="trace"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Program.js:</p>
  
  <pre><code>var myTable;
  
  // The initialize function is required for all apps.
  Office.initialize = function (reason) {
      $(document).ready(function () {
  
          myTable = new Office.TableData();
          myTable.headers = ["First Name", "Last Name", "Grade"];
          myTable.rows = [["Brittney", "Booker", "A"], ["Sanjit", "Pandit", "C"], ["Naomi", "Peacock", "B"]];
  
          try {
              Office.context.document.bindings.addFromNamedItemAsync('TheTable',
                  Office.BindingType.Text, { id: 'tbl' },
                      function (result) {
                          if (result.status === Office.AsyncResultStatus.Succeeded) {
                              trace('Control bound. Binding.id: ' + result.value.id + ' Binding.type: ' + result.value.type);
                          } else {
                              trace('Error:', result.error.message);
                          }
                      });
  
          } catch (e) { trace("Exception: " + e.message); }
      });
  }
  
  //THIS WORKS!
  function addHTML() {
      try {
          Office.select("bindings#tbl").setDataAsync("&lt;table border='1' width='100%'&gt;&lt;thead&gt;&lt;tr&gt;&lt;th style='background-color:#ff00ff'&gt;Description&lt;/th&gt;&lt;th&gt;From&lt;/th&gt;&lt;th&gt;To&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;/table&gt;", { coercionType: "html" },
              function (asyncResult) {
                  if (asyncResult.status == "failed") {
                      trace('Error with addHTML : ' + asyncResult.error.message);
                  } else { trace("Success calling addHTML()"); }
              });
  
      } catch (e) { trace("Exception: " + e.message); }
  }
  //THIS WORKS!
  function addRowsAtSelection() {
  
      try {
          Office.context.document.setSelectedDataAsync(myTable, { coercionType: Office.CoercionType.Table },
              function (result) {
                  var error = result.error
                  if (result.status === Office.AsyncResultStatus.Failed) {
                      trace(error.name + ": " + error.message);
                  } else { trace("Success calling addRowsAtSelection"); }
              });
      } catch (e) { trace("Exception: " + e.message); }
  }
  
  //FAIL!
  function addRowsWithoutSelection() {
      try {
          Office.select("bindings#tbl").setDataAsync(myTable, { coercionType: Office.CoercionType.Table },
              function (asyncResult) {
                  if (asyncResult.status == "failed") {
                      trace("Action failed with error: " + asyncResult.error.message);
                  } else { trace("Success with addRowsWithoutSelection.");}
              });
      } catch (e) {trace("Exception: " + e.message);}
  }
  
  //WORKS!
  function navigateToBinding() {
      Office.context.document.goToByIdAsync("tbl", Office.GoToType.Binding, function (asyncResult) {
          if (asyncResult.status == "failed") {
              trace("Go To Binding failed with error: " + asyncResult.error.message);
          }
          else {
              trace("Navigation successful");
              try {
                  Office.context.document.setSelectedDataAsync(myTable, { coercionType: Office.CoercionType.Table },
                     function (asyncResult) {
                         if (asyncResult.status == "failed") {
                             trace("Action failed with error: " + asyncResult.error.message);
                         } else { trace("Success with addRowsWithoutSelection."); }
                     });
              } catch (e) { trace("Exception: " + e.message); }
          }
      });
  }
  function trace(msg) {
      $("#trace").append(msg + "&lt;br /&gt;");
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/e6bHc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e6bHc.png" alt="enter image description here"></a></p>