

It also sets the variable "content" to the search text I placed in the template as explained above, "**Name**" set content of replacement of selFind to name I just told Word "Find every instance of "**Name**" and replace it with the variable "Name" execute find replace replace all Word knows what I want it to do. tell selFind set content to "**Name**" This starts up the find and replace process. I think it selects the entire document for the find/replace action. set selFind to find object of selection I'm a bit clueless on this line but the script fails if it is not there. All Caps, bold, etc.) - Name Another comment telling me I'm about to do the find and replace on the Name variable. In setting it up this way you don't need to bother Applescripting the formatting because the script just uses whatever formatting you chose in the template (i.e. For instance the name section of the document is written "**Name**". When you create the template it is important that you distinguish the phrases you plan on replacing. Obviously the location of your document template may vary slightly. In this example I've created a template (.dot extension) in word called "Piano Legends.dot".

open "Macintosh HD:Users:david:Library:Application Support:Microsoft:Office:User Templates:My Templates:Piano Legends.dot" If you are going to be creating forms you first need to create a template in word. tell application "Microsoft Word" Now we are getting to the good stuff.
Add fillable fields in microsoft word 2008 for mac code#
This line of code creates a new variable called "name" and fixes the problem. Simply putting up the dialog box does not create a variable that can be used to fill in a Word form. set response1 to display dialog "Type in the name you want to paste" default answer "Thelonious Monk" This line does two things: First it pops up a dialog box that says "Type in the name you want to paste" Second it fills in the box with a default answer of "Thelonious Monk" (Has anyone figured out yet what a big Monk fan I am?) set name to text returned of response This was the line that vexxed me the most. I named each with a remark so I can get back to where I need easily to debug if necessary. This sample has only one variable but the actual script has twelve variables. Dialog Box to Get Information The two dashes make this line a remark so the program basically ignores it. If you are a complete Applescript newbie you need to first open Script Editor which can be found in the Applescript subdirectory of you Applications folder and then copy the above script in. Dialog Box to Get Information set response to display dialog "Type in the name you want to paste" default answer "Thelonious Monk" set name to text returned of response tell application "Microsoft Word" open "Macintosh HD:Users:david:Library:Application Support:Microsoft:Office:User Templates:My Templates:Piano Legends.dot" - Name set selFind to find object of selection tell selFind set content to "**Name**" set content of replacement of selFind to name execute find replace replace all end tell end tell So breaking it down let me explain as best as my tiny programming brain can. So I'm going to list the whole script below and then I'm going to break it into pieces. I'm no expert at this and I'm pretty sure this could get better but at least my script is functional and hopefully saves the next person from the trouble of starting from scratch.

So I spent a few hours today learning to Applescript and came up with the script I'm reporting below.

You think there would be guides all over the InterWeb for this but I couldn't find any. date, corporate officers and directors) and then goes off and opens the form and fills in the basic information for me. I would like to have a system where I can run a program that prompts me for certain bits of information (i.e. For instance, sometimes I have a client that needs a set of corporate minutes. As a result I have a few forms that I find myself using repeatedly. One of the things I do during the day job includes a lot of corporate transactional work. Okay gang, put on your propeller beanie caps.
