Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clear Clipboard from code - is it possible?

Status
Not open for further replies.

Roosters

Technical User
May 14, 2000
61
AU
Are you able to clear the contents of the clipboard via code?
Thanks Phil
 
how are ya Roosters . . .

. . . or you can use the API method:
In a the declaration section of a module in the modules window copy/paste the following:
Code:
[blue]Public Declare Function EmptyClipboard Lib "user32" () As Long
Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function CloseClipboard Lib "user32" () As Long[/blue]
In the body of the module copy/paste the following function:
Code:
[blue]Public Sub ClearClipBoard(frm As Form)
   OpenClipboard frm.hwnd
   EmptyClipboard
   CloseClipboard
End Sub[/blue]
From any form or subform to clear the clipboard:
Code:
[blue]   Call ClearClipBoard(Me)[/blue]
Thats it! . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Be aware that the clipboard is generally intended for the user. I would find any programme that cleared my clipboard intensely irritating.
 
Howdy Remou! . . .

It appears to me that [blue]Roosters[/blue] has a definite [blue]VBA need[/blue] and not a user need! (at least from whats presented) . . . I have no problem with this! . . . apparently you do! . . .

Hay, its caled different strokes for different folks . . . ya think! . . .

You always seem to abide that members here should think exactly like you! . . . I've lived long enough to know that this is not possible! . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
I will be more careful to quote my sources when commenting. The above comment is based on reading Microsoft documents as well as my own experience. For example (my bolding):

[tt]Deprecated Application Programming Interfaces
For the CopyFace and PasteFace methods, use Picture and Mask properties instead. To copy the image from a built-in Office CommandBarButton, use FaceId. The CopyFace and PasteFace methods modify the Microsoft Windows® clipboard which can be frustrating for users who don't understand why their clipboard data is corrupted or overwritten. Picture and Mask can also support gradients in Office 2003 running on Windows XP using themes.[/tt]

-- Best Practices When Developing Command Bars for the Microsoft Office System
 
Haaaaay [blue]Remou![/blue] . . .

Don't take it the wrong way . . . My respect for you will never change! [thumbsup2]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top