title: How can I programmatically set text to "Small Caps" in InDesign with ExtendScript?
body: <p>I'm trying to do the equivalent of selecting some text and clicking on the <em>Small Caps</em> button. Here are a few attempts:</p>
  
  <pre><code>app.activeDocument.textFrames[0].texts.appliedCharacterStyle.capitalization = Capitalization.SMALL_CAPS;
  </code></pre>
  
  <p>Doesn't work: "Invalid request on a root style"</p>
  
  <pre><code>var myCharacterStyle = new CharacterStyle();
  myCharacterStyle.capitalization = Capitalization.SMALL_CAPS;
  app.activeDocument.textFrames[0].texts[0].applyCharacterStyle(myCharacterStyle);
  </code></pre>
  
  <p>Doesn't work: "Invalid value for parameter 'using' of method 'applyCharacterStyle'. Expected CharacterStyle, but received nothing."</p>
  
  <p>How am I supposed to do this?</p>