Applescript Find & Replace in Text Document from Excel Sheet
<p>I'm new to <code>Applescript</code> and am trying to create a script that can run through a text document (.html) and find &amp; replace various phrases with a corresponding cell in an Excel document. </p>

<p>I will put placeholders in the text to be replaced as <code>B_1 (first value to replace), B_2 (second), B_3</code> etc...</p>

<p>They should be replaced in order using the cells <code>B1-B9</code> in the Excel document. The phrases in the Excel document will be changed each time, hence why it has to be dynamic to capture them rather than a standard find &amp; replace script with static values.</p>

<p>I've been following this thread which all makes sense: <a href="https://discussions.apple.com/thread/7008048?start=0&amp;tstart=0" rel="nofollow">https://discussions.apple.com/thread/7008048?start=0&amp;tstart=0</a></p>

<p>However, I keep running into compile errors. Here is my current code:</p>

<pre><code>tell application "Microsoft Excel"
set colB_data to value of every cell of range "B1:B9" of worksheet 1 of document 1
end tell

tell application "Sublime Text"
tell text of "Users/maxquinn/Desktop/index.html"
repeat with index from 1 to count colB_data
replace ("B_" &amp; index as text) using (item index of colB_data) options {starting at top:true, match words:true}
end repeat
end tell
end tell
</code></pre>

<p>The first half works fine, but the second half gives me the error <code>"Expected end of line but found identifier."</code> and highlights the <code>'using'</code> in the <code>'replace' command (line 8)</code>.</p>

<p>Does anyone know why this might be, and are there any other glaring errors in the script?</p>

<p>Thanks!</p>

<p>Max</p>