Thanks for your suggestion. I am not bothered whether clipboard is
cleared or not. For my purpose, I need to get data from a selection
and modify it in a format I wanted and put it in the clipboard so that
another application can take that data. There is no other way for me
to pass that data to that application. This bug occurs only on Mac OSX
excel and it is fine on Mac OS9 and on Windows. I think the problem is
in "putInClipboard method of DataObject. If I just copy with short cut
keys (or from menu) and pasting into BBEdit i don't see any extra
characters.
"J.E. McGimpsey" <jemcgimpsey.TakeThisOut@mvps.org> wrote in message news:<jemcgimpsey-592D64.14255112112003.TakeThisOut@msnews.microsoft.com>...
> In article <4b28eff8.0311120740.a6d1a61.TakeThisOut@posting.google.com>,
> subrahmanyam.kunala.TakeThisOut@regeneron.com (subra) wrote:
>
> > putInClipboard method of the DataObject is putting some invisible
> > characters on clipboard at the end of the string. I can see these
> > characters when i paste the clipboard conetents in BBedit. This
> > happens only on Mac (OSX). I don't have any problem on windows. I
> > figured out that for every character in the string one invisible
> > character is added at the end plus two ( if i have 10 character
> > string, there are 12 invisible characters). Also when I use GetText I
> > don't get anything. Following is my test code. I appreciate any
> > suggestions.
> >
> > Dim data As DataObject
> > Dim text, rs As String
> >
> > For i = 1 To 100 Step 1
> > text = text & "hello"
> > Next
> >
> > Set data = New DataObject
> > data.SetText text
> > data.PutInClipboard
> >
> > data.GetFromClipboard
> > rs = data.GetText
> > ' no text in my immediate window
> > Debug.Print rs
>
> I can reproduce your results in PutInClipboard, except that I get
> the invisible characters plus one extra character, not two (all
> Unicode 255). I don't know if this has been bugged before, but I'll
> submit it. Please do likewise, using XLv.X's Help/Send Feedback
> feature.
>
> AFAIK, the GetText problem's been a bug in MacXL since XL98. I know
> that I and others have reported the problem, so perhaps the next
> version...
>
> In the mean time, the best workaround I've found is to paste the
> contents of the clipboard into a cell in a new workbook, read it
> into a string variable, then delete that workbook.
>
> Depending on what you're doing, of course, you may not need to. The
> Mac clipboard is persistent - Application.CutCopyMode = False does
> not clear it - so you may not need to read it into a dataobject at
> all.
>
> For a macro that *does* clear the Mac clipboard, see
>
<font color=purple> > <a style='text-decoration: underline;' href="http://www.mcgimpsey.com/excel/clearclipboard.html</font" target="_blank">http://www.mcgimpsey.com/excel/clearclipboard.html</font</a>><!-- ~MESSAGE_AFTER~ -->
>> Stay informed about: putInClipboard method errors on mac