Re: Word scripting?
Re: Word scripting?
- Subject: Re: Word scripting?
- From: Dave Groover <email@hidden>
- Date: Mon, 24 Mar 2003 14:22:52 -0500
Thanks Paul, JD,
From an earlier reply (JD) I learned how to move the insertion point.
I didn't realize that Word was so finicky to script. My only reason
for wanting to use it was because I have built a contact DB and I
want to have it generate letters and emails. I can also use my db
program to write the letters but I thought using the more standard
Word app would make it a little easier to keep track of the archived
letter files.
Of course, this is not rocket science. All I want to do is paste in a
header, or open a letter template, put in the address, date, to,
sincerely fields, save as and type it.
Perhaps Nisus will finish their cocoa X version of their WP soon. I
started with Nisus long ago. And I hear that the Nisus email app sits
as a watched folder so sending emails to it from a db makes sending
emails very easy. OTO, my db app (Panorama) promises an X upgrade
(any month now) that should include TCP/IP functionality for the
first time. (promises of immanent releases aside).
But if Word needs a whole other language then I will definitely
rethink using it as my letter program of choice. I would still want
to translate into word as most others on the planet, in the business
world, use MS Word files.
Ah well.
Dave
On 3/23/03 1:29 PM, "Dave Groover" <email@hidden> wrote:
> Can someone enlighten me as to how I can or should, improve my Word
script? If someone can show me an example of one already done, so
much the better. Here is what I have and the minimum I would like
help with:
tell application "Microsoft Word"
make new document
make new line at window 1 with data AddressOnClipboard
set justification of line 5 to right
> end tell
This is to write a letter from a contacts record in my DB.
I have a block of address data that is parsed to the AS from my DB
(Panorama). It includes the current date and a dear (first name) and
an ending. I could also get the Word app to insert the proper date
and header pieces but so far my Word app is not responding to the Do
script examples as shown in the Danny Goodman book. And in the short
run, it is easier to at least throw the data into the blank page pre
arranged. The problem however is that after I set the date to include
my closing, I want to move the insertion point back up to where I
want to start the letter (the body).
I am not finding how to move the insertion point, as a cursor only,
to the point where I want to start my typing of the letter. Can
someone suggest the correct phrase for this?
The scripting of Word is notoriously unreliable precisely for things like
this. It starts out OK, once you get your head around its 'text from 12 to
25' terminology, but then it goes all wrong. This is likely because Word is
not a text editor but a complex word processor, and has lots and lots of
invisible characters which control paragraph style, etc. It was never
properly translated for AppleScript, and probably can't be in the simple
text-editor way we'd like. Sooner or later you crash. It's not worth it.
The way to do it, for now, is by using 'do Visual Basic', which lets you do
VBA from AppleScript. If you get my script "Address Word Letter" or Address
Word Letter X" at
AppleScript Central <http://www.applescriptcentral.com/>
you'll see precisely how to move an insertion point. For general
instructions on how to use 'do Visual Basic', see
http://www.mvps.org/word/FAQs/WordMac/WordAppleScript.htm
To find the VBA terminology for a particular Word function, go to
Tools/Macro/Visual Basic Editor/Help/Word VB Contents (or Search). It's an
excellent Help Guide.
It's unfortunate that you have to learn another language (VBA) to script
Word reliably, but it's the only way that works at the moment. Once you get
into it, you'll see how incredibly powerful it is: it controls the whole
complex object model, not just simple text editing. There is some hope that
MS may be revising Word AppleScript for a future version.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.