Hi Craig,
Thanks for the offer, but I think it’s just some strange Word behavior that’s keeping me from getting exactly what I want. I got a working version now so don’t spend to much time on this, but if you want to look upon this as an expantion of your knowledge try this:
on open of finderObjects
repeat with sourceFile in (finderObjects)
tell application "Microsoft Word"
open sourceFile
save active document as (name of sourceFile)
close active document saving no
end tell
end repeat
end open
We use this to “convert” Windows Word files to Mac Word files (we noticed some strange behavior when importing Windows Word files into InDesign. This behavior disappears after this conversion). This works (notice the new date/time for the file(s)) when using Word files that come directly from Windows. It will do nothing when the file has been opened (and saved) on a Mac.
In a different script I use something similar to convert a text file to MAC-ASCII. Open a text file (coding unknown) in Word, save it as a text file and presto, a MAC-ASCII text file. This:
tell application "Microsoft Word"
open sourceFile
save as active document file name (name of sourceFile) file format format text
close active document saving no
end tell
however does nothing. Trying with different kinds of file names (full path name as you suggested etc) doesn’t help the situation. Omitting the file name bit (the Word dictionary has this to say about it:
save as document
[file name Unicode text] : The name for the document. The default is the current folder and file name. If a document with the specified file name already exists, the document is overwritten without the user being prompted first.
) schould do the trick, but no joy from that either.
So what I was looking for is starting with a text file with a certain name in a certain location and ending up with a slightly different text file with the same name in the same location. And all of this in one line of code. There are other, more cumbersome ways to get to this (that’s the working script I got now), but what bugs me is that it should work in just the one line… But some Word quirks may be invincible…
regards,
Ton
PS: A positive note on Bill’s boys; They did greatly expand the AppleScript possibilities in Word 2004, because all of this would not have been possible without VB in previous versions of Word…