Empty Clipboard using VBA

  • Thread starter Thread starter Mazza
  • Start date Start date
M

Mazza

Hi all,
I have a problem where users are copying data from fields in a form and
pasting it into another area. This procedure is only temporary but while
this is happening the clipboard seems to fill up.
What I would like is the code required, to put behind a button, that, when
clicked, will empty the clip board
Is there such code?
Thanks in advance to anyone that is able to assist me with this.

Mazza
 
' Here are the API Declarations to be placed at the top of the Form's
Class module

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


' Here is the code behind a CommandButton's Click event
' named "cmdClip"


Private Sub cmdClip_Click()
On Error GoTo Err_cmdClip_Click


' Open, Empty and Close Clipboard
' No Clipboard API error handling
Call OpenClipboard(0&)
EmptyClipboard
CloseClipboard


Exit_cmdClip_Click:
Exit Sub


Err_cmdClip_Click:
MsgBox Err.Description
Resume Exit_cmdClip_Click


End Sub



--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Thanks Stephen I will try it today


Stephen Lebans said:
' Here are the API Declarations to be placed at the top of the Form's
Class module

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


' Here is the code behind a CommandButton's Click event
' named "cmdClip"


Private Sub cmdClip_Click()
On Error GoTo Err_cmdClip_Click


' Open, Empty and Close Clipboard
' No Clipboard API error handling
Call OpenClipboard(0&)
EmptyClipboard
CloseClipboard


Exit_cmdClip_Click:
Exit Sub


Err_cmdClip_Click:
MsgBox Err.Description
Resume Exit_cmdClip_Click


End Sub



--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

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

Back
Top