September 19, 2016

Insert Verses Accordance Service Within Microsoft Word List Paragraph

It turns out that the "Insert Verses" Accordance Service breaks when highlighting a verse reference that begins the line of a List formatted paragraph in a Microsoft Word document.

So, in the above screen shot, you can select the first line and the Insert Verses Accordance Service will work great, but if you try it with the second line (which is formatted in a List style), it results in an error something like:
ERR-A valid book name must be entered at the selection point.
This is true for both Word 2011 and 2016. The reason for this is that when a selection in Word is copied and sent to the clipboard or the Accordance Service, Word "helpfully" includes the list item number or bullet in the copied text. (This is only an issue when the verse reference is at the beginning of the paragraph.)
Instead of just the reference, Word is actually sending:
1.[TAB]Gen 1.1

In Word 2010 for Windows, there is an option in File -> Options -> Advanced -> "Cut, copy, and paste" where you could change "Keep bullets and numbers when pasting text" to "Keep Text Only". This Advanced option does not exist in Word 2011 for Mac. (I do not know if it is available in Word 2016.)

As a fix, you can Get-Your-Geek-On and add a step in the Insert Verses Service to remove everything leading up to any TAB in the selection before sending the reference to Accordance. You can find information about editing or customizing Accordance Services in this blog post: Creating a New Automation Service for Accordance, but here are the basic steps for this tweak:

1. Find the "Acc- Insert Verses" workflow file in ~ / Library / Services.
2. Double-click that file to open it in Automator.
3. Drag a new "Run Applescript" Action from the Actions sidebar into the workflow, above the "Get Text From Accordance" Action.
4. Change the script text to:

on run {input}
set input to input as string
if input contains tab then
set AppleScript's text item delimiters to tab
set input to item 2 of (text items of input)
set AppleScript's text item delimiters to ""
end if
return input

end run

The result should look like this:

5. Save and use.