Re: How to preserve the user's clipboard contents?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Karl,

Thanks for the detailed answer and the links. I've never used VB (though I'd
like to learn), and I now understand the magnitude of this task.

I will follow your original advice--apologize to the users. ;)

Ben

"Karl E. Peterson" wrote:

Hi Ben --

Windows offers an API called RegisterClipboardFormat, which effectively
allows anyone to define any random binary structure as a custom format. In
theory, you could just store these as binary blobs, then put them back on
just as they were. But you're further complicated by CF_OWNERDISPLAY items,
in which the original application is called upon to draw on demand.

Do you do any plain-vanilla VB? If so, you might find
http://vb.mvps.org/samples/ClipView to be of interest. It enumerates the
formats available, and displays those it understands. You could diddle with
extending it to other formats, to get an idea of how that might be
approached by VB(A). Another demo, http://vb.mvps.org/samples/ClipEx, may
show you how to approach multiple formats through VBA.

But in the end, saving and restoring the clipboard will be a gargantuan task
that will probably never be 100%.

Sorry... Karl


Benjamino5 wrote:
Karl,

Thanks for the response, though it's disheartening. By "custom"
formats, do you mean that there are so many different data types it's
not possible to make a DataObject that could contain them?? Or...?

Here's another tack: can I access the multiple-item functionality of
the clipboard in VBA? I haven't found a way to do it yet, so perhaps
there isn't a way.

Ben

"Karl E. Peterson" wrote:

Benjamino5 wrote:
My template needs to use Selection.Range.Copy and other clipboard
operations.

However, any time I call a method that uses the clipboard, I will be
wiping out the *user's* own clipboard contents!

I'd like to write a sub that will take whatever's in the
clipboard--text AND pictures AND MathType objects, etc.--and store
it somewhere. Then, after my template uses the clipboard for its own
operations, it should restore the original contents of the
clipboard.

I imagine this is a common enough problem that many people here have
dealt with it. What do you do? Do you have any code samples I could
use?

Apologize. With humility and deep respect for your user. Or find
another way.

It's an impossible task, given Windows support of "custom" formats.
--
Working without a .NET?
http://classicvb.org/

--
Working without a .NET?
http://classicvb.org/



.



Relevant Pages

  • Re: Bitmap + Clipboard + Transparency = Blue Background?
    ... I don't suppose you have a list to the image formats for which ... a non alpha channel format before placing it on the clipboard. ... public void CopyToClipboard() ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Windows Clipboard Default Font Change
    ... The clipboard doesn't have a font, ... "fancy" formats like Rich Text Format and HTML ... Notepad placing anything other than plain text onto the clipboard. ...
    (microsoft.public.windowsxp.general)
  • Re: How to preserve the users clipboard contents?
    ... allows anyone to define any random binary structure as a custom format. ... formats available, ... saving and restoring the clipboard will be a gargantuan task ...
    (microsoft.public.word.vba.general)
  • Re: Delete Cropped Area
    ... is that the result of choosing Picture varies based on Apple's preferred ... The Windows Clipboard OTOH uses WMF/EMF I believe. ... like WMF/EMF/JPG/PNG etc and also private formats. ... I see are Microsoft Drawing Object (which doesn't delete the cropped-out ...
    (microsoft.public.mac.office.powerpoint)
  • Re: How to preserve the users clipboard contents?
    ... "Karl E. Peterson" wrote: ... custom format. ... enumerates the formats available, ... saving and restoring the clipboard will be a ...
    (microsoft.public.word.vba.general)