February 24, 2010

Create a Custom Paste Command in Word 2008

In Microsoft Word 2008, you can create custom Applescripts and the place them into a special folder giving them unique keyboard combo assignments. In this way, you can, create custom functions or combinations of functions that initiate with just one keystroke. For instance, let's say you wanted a simple paste command in Word, but one that first took care of some formatting changes for you. By way of example, let's say that you often copy scripture text from Accordance but before you paste it into your Word document, you want to remove the formatting and also remove the pilcrow symbols (¶) and the space following them from the text. A simple script can accomplish both tasks automatically for you.

1. Open Applescript Editor inside your Applications/Utilities folder (In OS X 10.5 this app is called Script Editor and found at Applications/Applescript)

2. Paste the following 7 lines into a new document window:

set theText to the clipboard
set AppleScript's text item delimiters to "¶ "
set theText to text items of theText
set AppleScript's text item delimiters to ""
set theText to theText as string
set the clipboard to theText
tell application "Microsoft Word" to paste special (text object of selection) data type paste text
(The last line of that script is kind of long, so make sure you do have it all on one line.)

3. Save the AppleScript as a script in ~/Documents/Microsoft User Data/Word Script Menu Items
(which is Word's user info inside the Documents folder of your Home folder). 

4. Give the script a descriptive name such as "Paste Scripture" but also add "\cV" (without the quotation marks) to the end of the name. This sets the keyboard combination to Control-v.  (for more info on adding keyboard shortcuts, have a look here.)

5. From now on, in Word, you can hit Control-v to run the script which will remove the Pilcrows ¶ and paste unformatted text into your document.

1 comment:

監控 said...

逛到你的部落格,第一個感覺就很好,希望每次更新都是美好的開始,也祝你天天都都開心喔........................................