I code sometimes. I also write. Occasionally the two come together.
As I’ve mentioned, coding helps me find new ways to think about my work. Here’s a new Applescript I whipped up to highlight instances of “to be” in my drafts, as well as certain filler words that don’t add much to the text. Open your document in MS Word, then run the following code. The selected words will be replaced with bold versions of themselves.
Alter the list as necessary, or use this as an example of how to do a list-based loop in Applescript (hint: the “repeat” line is key;). Enjoy!
set my_word_list to {"am", "are", "be", "been", "being", "felt", "had", "has", "have", "heard", "is", "looked", "was", "wasn't", "were", "weren't"} repeat with each_word in my_word_list set FindWordsToReplace to each_word as text tell application "Microsoft Word" set GetTxt to find object of selection tell GetTxt clear formatting set its content to FindWordsToReplace tell its replacement clear formatting set its content to FindWordsToReplace tell its font object set bold to true end tell end tell execute find wrap find find continue replace replace all with match forward and match whole word without match case end tell end tell end repeat
Reblogged this on SutoCom Solutions.