Clipboard Question

J

Josh Sale

I have and Excel 97 - 2003 add-in that under certain circumstances uses the
clipboard. Before using the clipboard I try to save its contents using code
like the following:

Dim MyDataObj As New DataObject
Dim SaveOfClipboard As Variant

MyDataObj.GetFromClipboard
SaveOfClipboard = MyDataObj.GetText()

so that I can restore it when I'm done in case the user has something of
interest to them on the clipboard.

This mostly works OK unless the user has a bunch of data on the clipboard in
which case only the first bit of clipboard data is saved using the above
code.

Is there a better/more complete way of quickly saving and restoring the
contents of the clipboard? I think doing a File | Save of the clipboard
will be too slow so I need something that performs better.

TIA,

josh
 
J

Josh Sale

David,

Thanks for the pointer to Chip's page. I clearly had found that page a few
years ago when I first added this feature because the code in question is
nearly identical to Chip's.

So it is with Chip's code that I'm having the problem with the text on the
clipboard being truncated. I can't really tell if the truncation occurs
when I try to save the contents (i.e., the code only gets a portion of the
clipboard's contents) or on restore (i.e., only a portion of what was
previously saved is restored).

Any further thoughts?

josh
 
D

David McRitchie

Hi Josh,
You may have already gotten a better answer, sorry for not checking first.

Are you copying from one cell in Excel, or from somewhere else.
If from somewhere else you could be exceeding limits in Excel.
Look up "specification" as in "specification limits" in Excel.
 
J

Josh Sale

Well David, I'm still searching for clipboard salvation.

My problem is that the user may have copy'ed a bunch of stuff onto the
clipboard ... that bunch of stuff is within Excel's limits.

Sometimes my code needs to use the clipboard (e.g., .Copy followed by
..PasteSpecial). In these cases I try to be a good citizen and save the
contents of the clipboard using Chip's code prior to using it myself. When
I'm done using the clipboard, I again use Chip's code to restore the
previously saved contents.

Its during either the save or restore that the stuff the user placed on the
clipboard is being truncated. My program's operation with the clipboard
works fine. If my code didn't try to use the clipboard, the user's stuff
would all be there just fine (e.g., they haven't exceeded Excel's limits).

So I'm just looking for the moral equivalent of Chip's code but without the
apparent size limitations.

Hope this makes things clearer.

TIA,

josh


David McRitchie said:
Hi Josh,
You may have already gotten a better answer, sorry for not checking first.

Are you copying from one cell in Excel, or from somewhere else.
If from somewhere else you could be exceeding limits in Excel.
Look up "specification" as in "specification limits" in Excel.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

David,

Thanks for the pointer to Chip's page. I clearly had found that page a few
years ago when I first added this feature because the code in question is
nearly identical to Chip's.

So it is with Chip's code that I'm having the problem with the text on the
clipboard being truncated. I can't really tell if the truncation occurs
when I try to save the contents (i.e., the code only gets a portion of the
clipboard's contents) or on restore (i.e., only a portion of what was
previously saved is restored).

Any further thoughts?

josh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top