RE: set the clipboard not available in in some apps (like Word)
RE: set the clipboard not available in in some apps (like Word)
- Subject: RE: set the clipboard not available in in some apps (like Word)
- From: "Scott Babcock" <email@hidden>
- Date: Mon, 13 Dec 2004 18:27:12 -0800
- Thread-topic: set the clipboard not available in in some apps (like Word)
OK, here's a much more useful explanation, and a much easier
work-around.
There is a bug in the 'paste' implementations of standard dialog text
fields and Word 2004, among others, which causes fits when the only
content on the clipboard is Unicode text. The work-around is to put a
string-format entry in the clipboard, too. It doesn't matter what the
content of this second entry is; it won't actually be used. It just
wakes up the code that processes the clipboard content and enables it to
accept the Unicode text entry. Here's a much easier way to accomplish
this than my previous suggestion (you'll need to replace the fake
guillemets with the real thing):
set utxt to <<data utxt2603263A>>
set reco to {Unicode text:utxt, string:""}
set the clipboard to reco
Paste to your heart's delight. This content will insert a snowman and a
smiley in Word 2004 and in standard dialog text fields.
-----Original Message-----
From: Scott Babcock
Sent: Monday, December 13, 2004 3:55 PM
To: 'email@hidden'
Subject: Re: set the clipboard not available in in some apps (like Word)
Another work-around is to use Perl to create a clipboard data record
with both 'TEXT' and 'utxt' elements. In AppleScript, write your Unicode
string to a file. Read this file into Perl, construct a record with
'TEXT' and 'utxt' elements, write this record to another file, read this
file as a record in AppleScript, and set the clipboard to this record.
I've done this myself, setting the content of each element to the same
UTF-16 (Unicode text) data. This clipboard content works in Word and in
other instances where having only 'utxt' content fails, like standard
dialog text fields.
-----Original Message-----
Date: Mon, 13 Dec 2004 09:50:53 -0800
From: Paul Berkowitz <email@hidden>
Subject: Re: set the clipboard not available in in some apps (like
Word)
To: AppleScript-Users <email@hidden>
Message-ID: <BDE3167D.80D68¾email@hidden>
Content-Type: text/plain; charset="US-ASCII"
On 12/12/04 1:12 PM, "Joseph Weaks" <email@hidden> wrote:
>
>> ...But it's really to do with
>> Word (or Office) having its own clipboard. They'll communicate
one-way
>> but
>> not the other way. We've seen that setting the clipboard to a string
>> via
>> AppleScript somehow is transferable to Word's clipboard, so it
pastes.
>> Unicode doesn't transfer from the system clipboard to Word's (I
expect
>> it's
>> still using an old-fashioned method of getting styles).
>
> I am not queazy about calling this a bug! At best, it's incomplete and
> poor Unicode implementation.
It's been confirmed by MS as a recently discovered bug. What's happening
is
this: legacy code in Word is looking just for 'TEXT' (plain text)
"flavor"
on the clipboard to see whether the clipboard's state is enabled or not,
rather than also checking 'UTXT' (Unicode text) flavor too. Normally
this is
not an issue, since every application that puts UTXT (or styled text or
graphics plus text, etc.) on the clipboard _also_ puts 'TEXT' version
there
too. That's why it works fine in the UI. It's _only_ AppleScript's 'set
the
clipboard' which doesn't bother to take the precaution of putting a
plain
text version for safety.
Frankly, IMO, this is also a "bug" - legacy code in Standard Additions
that
has not been brought up to date - that 'set the clipboard' does not take
this same elementary precaution that all applications take. In any case,
a
later version of Word will check all flavors on the clipboard.
If you wanted, you could get around this in a Studio app by using 'call
method' with NSPasteboard methods to get your text box or text field
data to
the clipboard, rather than 'set the clipboard'. I had to do that in one
of
my Studio apps in order to get attributed strings (colored formatted
text)
with graphics up there. There's a default for always including the plain
text version, and that would trigger Word's clipboard check.
NSPasteboard
methods can get a bit complicated - and of course we're mostly using
Studio
so as not to have to learn all that Objective C stuff. But - not for the
first time - it tends to work better...
Anyway - if Chris N. is reading here - this is a request for the
Standard
Addition's 'set the clipboard' to always include a plain text 'TEXT'
default
flavor _even when_ the text being specified is Unicode text. I can bug
this
if need be.
--
Paul Berkowitz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden