title: Creating Rainbow Text in Google Docs
body: <pre><code>var selectedElements = selection.getSelectedElements();
  for (var i = 0; i &lt; selectedElements.length; ++i) {
  var selectedElement = selectedElements[i];
  
  // Only modify elements that can be edited as text; skip images and other
  // non-text elements.
  var text = selectedElement.getElement().editAsText();
  
  // Change the background color of the selected part of the element, or the
  // full element if it's completely selected.
  if (selectedElement.isPartial()) {
    text.setColor(selectedElement.getStartOffset(),
        selectedElement.getEndOffsetInclusive(), '#69359c');
      }
    }
  }
  </code></pre>
  
  <p>The above text takes a selection inside of a Google Doc and changes it to the hex code #69359c (a dark purple). I have searched many websites, many gits, and asked many friends for help with my project.</p>
  
  <p>My end project is this:</p>
  
  <ol>
  <li>Create a menu for Google Docs with my selector (DONE)</li>
  <li>Be able to highlight a certain amount of text and change it to an array of colors (ROY G. BIV / the rainbow).</li>
  <li>Have the format be only for Google Documents.</li>
  </ol>
  
  <p>If anyone can help me it would be highly appreciated. </p>