Re: Word scripting?
Re: Word scripting?
- Subject: Re: Word scripting?
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 25 Mar 2003 08:40:58 -0800
On 3/25/03 1:59 AM, "David Wignall" <email@hidden> wrote:
>
Thinking it through a little more slowly: my approach is that I can pass
>
variables from the AppleScript part to the 'do Visual Basic' well enough, as
>
long as I keep track of the plethora of quote marks that ensue, but I've
>
never had much success going the other way. Along the same lines you can't,
>
AFAIK, create a VBA function via AppleScript. So, for these and similar
>
reasons, I've always worked entirely in VBA. However if this was all to be
>
in a template then you could simply script the creation of a new document
>
based on that template and let Document_new or AutoNew direct things from
>
that point on.
Actually, you can. The 'MacScript' function in VBA is very powerful, and
lets you run any AppleScript at all, again quoted as a string. (It's listed
in the basic VB functions in VB Help - not part of Word VBA but available to
Word, Excel, PPT.) You need to include " & vbCr & " (or " & Chr(13) & ")
between every line in a multi-line AppleScript. You can also use it to
_call_ an applet or compiled script using the file path: it's just like 'run
script' in being able to do both. I have even used MacScript within 'do
Visual Basic' (the quoting conventions get very hairy).
You are right that 'do Visual Basic' does not return a result to
AppleScript. But I figured out a way to do it: you simply convert your
result(s) to string, separated by commas or tabs or return or any other
separator, if you have several results, and write it to a text file with the
VB commands Open for Output and Print #FileNumber (identical to our 'open
for access' and write') and then read that back in AS with 'read', then
delete the file. It works great. (You can even use MacScript and the
AppleScript 'open for access' etc if you prefer, within the do Visual
Basic.) I did the whole thing from a compiled script running in the
Entourage script menu, since it also scripts Entourage: it sends information
from Entourage to Word, lets the user interact with Word and sends the
resulting info back to a property in the script in Entourage which is stored
for further occasions.
--
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.