Same old problem… this runs in OS9 but not in OSX (which I don’t have easy access to!). You drop a bunch of Word docs onto it, and it strips out the text from each and collects it in a text file…
on open docList
copy (choose file name) as string to dataFile
open for access file (dataFile) with write permission
repeat with theFile in docList
set theFile to (theFile as text)
tell application "Microsoft Word"
open theFile
set theText to every text
close document 1
end tell
write theText & return & return to file (dataFile) starting at eof
end repeat
close access file (dataFile)
end open
the problem comes at the ‘open’ command in Word. I haven’t been able to find any sample scripts for Word. But it works in OS9.
My problem is partly the huge number of environments in this workplace.- classic Macs, OSX running Word under Classic, OSC running native Word…
My problem is now narrowed down to the fact that the following runs under OS9 but not under OSX - if anyone can duplicate and solve this, I would be very grateful!
on open docList
repeat with theFile in docList
tell application "Finder"
set theFolderName to (container of theFile) as string
if theFolderName does not end with ":" then
set theFolderName to (theFolderName & ":")
end if
set theFileName to (name of theFile)
set theFileSpec to (theFolderName & theFileName)
end tell
tell application "Microsoft Word"
try
open file theFileSpec
on error ErrorText
display dialog ErrorText
end try
end tell
end repeat
end open
The error comes when Word (OSX native) tries to open the file. Word running under Classic on an OSX machine seems to hang altogether. The script behaves perfectly under OS9 (I hate OSX!)
Does this work as far as opening the files? I tested it (quickly) only in OS X 10.3.9 and it works fine.
on open docList
tell application "Finder"
set word_path to application file id "MSWD" as text
repeat with theFile in docList
try
open theFile using word_path
on error ErrorText
display dialog ErrorText
end try
end repeat
end tell
end open