Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Applications > office 2008 scripting question

office 2008 scripting question
Thread Tools
Forum Regular
Join Date: Mar 2001
Location: canada
Status: Offline
Reply With Quote
Jun 25, 2008, 10:20 PM
 
Hi,

This question might be more suited to the developer forum, but I figure it's not too out of place here and may get a slightly wider audience. I'm an experienced software developer (mostly Java and a bunch of Cocoa) but I know very little about AppleScript or Microsoft Office. Please excuse any errors in the terminology I use.

I'm trying to figure out how to go through a Microsoft Word file (probably a template .dotx, actually, but whatever) and replace certain pre-determined "fields" with user-supplied data. Kind of like a mail merge, I guess, but ideally I'd like to pop up a dialog that the user can fill out, press "OK" and have all the relevant portions of the document be replaced appropriately.

The version of Word is 2008, so from the cursory amount of research I've done it seems like AppleScript Studio is what I want to be using - Interface Builder to create a fancy dialog and AppleScript to talk to Word to actually go through and replace the placeholder data.

(Is "AppleScript Studio" just a blanket term for somehow being able to combine Interface Builder nibs with AppleScript? Obviously I need to look into this more.)


Anyway, to summarize the basic workflow I have in mind:
- The user opens MyFile.dotx, so a pre-cooked document opens as "Document1"
- The user opens the (e.g.) "Enter Data" script from the scripting menu
- A dialog opens up with various text fields, drop-down lists, etc. that does some validation (like makes sure all required fields have been filled out) before the user can click the "Populate" button
- The appropriate placeholders in Document1 are updated with the data the user entered in the dialog
- Bonus points if the document can get saved to a pre-determined (likely read in from a config file or something?) location based on something the user entered in the dialog


This seems like a reasonably common use case, so I'm hoping someone here has done something like this before and can point me in the right direction. Obviously I need to familiarize myself with AppleScript in general, but I'm clueless about which commands I should be trying to send ("tell"?) Office, and especially how I should structure the .dotx template such that there are portions of the document I can identify via AppleScript and update with the data.
To tell the truth at this point I don't even know how to go about making a fancy dialog that I can open from an AppleScript, but Google has found me a couple tutorials so I don't think that'll be too tough to get going.

Thanks in advance for any help!

-parsec
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:29 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2