Re: Can anyone explain Word behavior???
Re: Can anyone explain Word behavior???
- Subject: Re: Can anyone explain Word behavior???
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 15 Mar 2001 00:04:31 -0800
On 3/14/01 8:08 PM, "Patrick Wynne" <email@hidden> wrote:
>
Paul Berkowitz <email@hidden> wrote:
>
>
> Back in the main VB language Reference read up on
>
> the MacScript method -it's the way you call AppleScript within
>
> VB the same way you call VB within AppleScript - very nifty. You
>
> can put an entire AppleScript in quotes or in a variable, or
>
> call an applet by its file path, just as in AppleScript you can
>
> put a whole VB script in quotes or else call an installed macro.
>
> In both cases you have to remember to convert line endings, but
>
> it means the two languages can talk back and forth to each
>
> other.)
>
>
Has anyone actually gotten this to work? I know that I've tried many,
>
many times over the last year or so and every time I get an error when
>
I try to use the MacScript command, whether with script statements or
>
trying to call an applet. I even asked on this very list if anyone had
>
gotten it to work and received one negative reply (and no positive
>
ones).
>
>
I'd really like to know how to make this work. Any help?
>
Yes, I got it to work. Someone wanted to know how to collapse a window in
Word:mac from a VB script . VB window commands only know about the Windows
type of maximize and minimize. i provided a one-liner MacScript command
using Akua Sweets to collapse the windows:
MacScript "tell application ""Microsoft Word"" to reposition window
""Document1"" with collapsing"
As you can see, you have to use the VB escape convention for quotes, which
is to double them (like AppleScript uses \", VB does ""). Maybe that was
your problem? Anyway, it works.
You'd also need to put in the right sort of line endings if using
multi-lined scripts. You couldn't put in a normal carriage return because
within VB that would get interpreted as a CRLF, which would mess up the
AppleScript. The best way would probably to do something like:
MacScript ("tell application ""Microsoft Word""" & vbCr & " reposition
window ""Document1"" with collapsing" & vbCr & "end tell")
In practice, you'd run your script through a handler to replace (return)
with
" & vbCr & "
at the end of every line, then set the whole result to a variable asScript,
then just give the command
MacScript asScript
--
Paul Berkowitz