So I have this code thats been working great, reading some Unicode text and putting it into the clipboard. That is, worked great till I sent it out for testing and a bunch of people said it doesn’t work in MS Word. I get a hold of Word 2004 (the one that comes in Office 2004), and heres what I find out. Well, first off, heres my code:
on run input
set thePath to input as POSIX file
set the clipboard to read_file(thePath)
end run
on read_file(the_file)
set the_file to the_file as string
try
open for access file the_file
set the_output to read file the_file as Unicode text
close access file the_file
return the_output
on error the_error
try
close access file the_file
end try
return the_error
end try
end read_file
The input is the POSIX filename I’m giving it, no problems there. This script is widget based, so I have to have it read the Unicode from a file (passing the Unicode doesn’t work, as Terminal doesn’t like it). Anyway, it works great in every Apple app (TextEdit, Pages, Keynote) and every other app I’ve tested on that supports Unicode. However, when going into Word, the stuff gets to the clipboard fine, but Word doesn’t like it and won’t paste. I can paste into TextEdit, recopy and its fine, but going straight to Word doesn’t work. I can’t try reading as <>, as what I’m outputting is utf16, so it “Can’t make some data into the expected type.” Any ideas as to why Word doesn’t like it and what I can do about it? As much as I hate Word as an application, it needs to be supported.