MACSCRPT Archives

June 2010

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Paul Berkowitz <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Sun, 6 Jun 2010 10:59:22 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (56 lines)
On 6/5/10 8:37 PM, "Nobumi Iyanaga" <[log in to unmask]> wrote:

> I tried this. Very curiously, this seems to do nothing at all...
> 
> But using your code as a hint, I tried this:
> 
> set fpath to "Macintosh HD:Users:[me]:Documents:mywork.doc"
> 
> set AppleScript's text item delimiters to {""}
> tell application "Microsoft Word"
> activate
> open fpath
> set thePath to full name of active document
> tell me
> set oldTIDs to text item delimiters of AppleScript
> set AppleScript's text item delimiters to {"."}
> set newDocPath to text items 1 thru -2 of thePath & "rtf" as string
> set AppleScript's text item delimiters to oldTIDs
> end tell
> tell document 1
> save as file name (newDocPath) file format format rtf
> close
> end tell
> end tell
> 
> And this time, it seems to work well. Although I still don't
> understand the reason why some code works, and some others don't, I
> think my problem is solved.
> 
> Thank you VERY MUCH!

Yes, that's the right way to do it. Since the new Word scripting (Word 2004,
improved 2008), you should use the 'save as' terminology in the Microsoft
Word Suite, rather than the "old" 'save' terminology from the Standard
Suite, at least when you're doing anything other than a plain 'save' with no
parameters.

The 'save as' command, like everything else in all suites except Standard,
is part of a thoroughgoing revision of Word's applescripting, built directly
upon its OLE Automation underpinnings, that mirrors the Visual Basic
language which was always better functioning than the old AppleScript model.
They kept the Standard Suite, or much of it, I guess to make people
unfamiliar with the more complicated (and contorted) new model more
comfortable. But it doesn't work any better than it ever did, and perhaps
worse. (Also, I'm not sure, but I think that the 'as file specification'
thing that John mentions may have been deprecated in newer OS's, or at least
Word's hooks into it no longer work. But that's a separate issue.)

What it comes down to is that the 'as' [type] parameter with the 'save'
command does not work as advertised, whereas the 'file format' parameter,
and all the other parameter, supplied with the 'save as' command in the MS
Word Suite, works just fine. Stick with that.

-- 
Paul Berkowitz

ATOM RSS1 RSS2