How do I clear the clipboard?

R

Radycal

I've done a lot of copying and pasting. I am now getting, "The data on the
Clipboard is damaged, so Microsoft Offfice Access can't paste it."

I'm using M/S Access 2007.

How do I clear the clipboard in M/S Excel or Access?

Thx,
Mike
 
A

Arvin Meyer [MVP]

Since it's not a regular thing, I just do it from Windows:

Start >>> Run >>> clipbrd.exe

In Vista I think it's clip.exe (but I'm not sure)
 
B

Banana

As Arvin said, it's not a regular thing.

However, is this concurring on a regular or maybe semi-regular basis? If
it was one-time fluke or once a month, then we can chalk it to gnomes.
But if it's regular, then I think we may want to look closer at the
processing and see how we may be unknowingly contributing to the
corruption.

How do you usually copy and paste? It sounds like it's between Excel and
Access, yes?

Also, to throw out a workaround, you may want to think about simply just
automating the import rather than manually copying and pasting.
 
P

Paul Shapiro

Or you can use the Windows API call.

'Include this line in the module header, before the first procedure, or
change it to Public and include it in any module.
Private Declare Function EmptyClipboard Lib "user32" () As Long

Then anywhere in the module,
Call EmptyClipboard
 
T

Tom Wickerath

Hi Paul,

I just tested your suggestion, but I cannot get it to work on my system. I
thought for sure it would work, because I noticed the same exact declaration
in KB 210216, along with code that reads as follows:

' Clear the Clipboard.
X = EmptyClipboard()

Yet, everything I try, either from the Immediate Window, or from a new
subroutine just to call the EmptyClipboard function, does not seem to empty
it on my PC.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________

:

Or you can use the Windows API call.

'Include this line in the module header, before the first procedure, or
change it to Public and include it in any module.
Private Declare Function EmptyClipboard Lib "user32" () As Long

Then anywhere in the module,
Call EmptyClipboard
__________________________________________

"Tom Wickerath" wote:

Hi Mike,

Try the code in this KB article:

How to Send Information to the Clipboard
http://support.microsoft.com/kb/210216

To clear the clipboard, send a zero length string:

ClipBoard_SetData("")


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
__________________________________________

:

I've done a lot of copying and pasting. I am now getting, "The data on the
Clipboard is damaged, so Microsoft Offfice Access can't paste it."

I'm using M/S Access 2007.

How do I clear the clipboard in M/S Excel or Access?

Thx,
Mike
 
K

Kevin Smith

I normally use this to empty the clipboard

Declare Function CloseClipboard Lib "user32" () As Long
Declare Function EmptyClipboard Lib "user32" () As Long
Declare Function OpenClipboard Lib "user32" (ByVal hWnd As Long) As Long

Sub ClearClipboard()
OpenClipboard 0&
EmptyClipboard
CloseClipboard
End Sub

I have this in a module on its own and just use "call ClearClipboard"
 
P

Paul Shapiro

Thanks much to both Tom and Kevin for testing the code more carefully than I
did. The only places I called EmptyClipboard in my code was in the middle of
code that had already opened the clipboard, so my code worked (accidentally
it turns out), but I didn't understand the requirements. Thank you both.
 

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