View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
NickH[_3_] NickH[_3_] is offline
external usenet poster
 
Posts: 15
Default VBA Clear clipboard

Thanks for such prompt response, Leith

I have tried this, but it doesn't appear to work. If I step through the
module, Ret always gets a value of 1, even on consecutive runs. With the
clibboard visible, the contents remain unchanged.

I don't know if it's relevant, but I'm using Office 2003 and I'm looking at
the "Office Cliboard" which indicates "1 of 24" entries as I type. The
source data comes from an Outlook message, which I copy manually (<ctrl-C).

--
Nick


"Leith Ross" wrote:


Hello Nick,

Add a VBA module to your project and add this code to it.

CALLING THE MACRO:
ClearClipboard


Code:
--------------------

Declare Function OpenClipboard _
Lib "User32.dll" _
(ByVal hWndNewOwner As Long) As Long

Declare Function EmptyClipboard _
Lib "User32.dll" () As Long

Declare Function CloseClipboard _
Lib "User32.dll" () As Long

Public Sub ClearClipboard()

Dim Ret

Ret = OpenClipboard(0&)
If Ret < 0 Then Ret = EmptyClipboard
CloseClipboard

End Sub

--------------------

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=484632