title: MacOS Automator + Applescript solution for exporting docx to pdf
body: <p>Scratching my head after reading lots of different threads on this and tried a bunch of scripts but none seem to work.</p>
  
  <p>I'd like to use Automator to automate Word 2016 conversion of a selection of docx files to pdf. </p>
  
  <p><br>
  Used the following Automator Service:</p>
  
  <p><a href="https://i.stack.imgur.com/YgJuG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YgJuG.png" alt="enter image description here"></a> </p>
  
  <p><br>
  Used the following script:</p>
  
  <pre><code>on run {input, parameters}
      tell application id "com.microsoft.Word"
          activate
          open input
          set doc to name of active window
          set theOutputPath to (input &amp; ".pdf")
          save as active document file name theOutputPath file format format PDF
      end tell
  end run
  </code></pre>
  
  <p><br>
  Which results in error: <strong>Microsoft Word got an error: active document doesn’t understand the “save as” message.</strong></p>