I have a bunch of excel macros running back-office functions, and my users were accidentally copying out data that had been copied by VBA macros into other places (this is not good).
I did some googled and found the typical "just use application.cutcopymode = false" answer all over the internet.
Unfortunately this does not work, at least not in Windows 10 with Excel in office 365, so I had to be creative.
I found a good starting place on this post: vbaexpress.com/kb/getarticle.php?kb_id=205
This pointed me in the right direction, and after some small changes I found a way to clear my clipboard every time.
Here is the code, with my comments:
'THE CODE BELOW WAS CREATED AND PUT IN ALL TRACKERS TO STOP USERS FROM COPYING OUT CONFIDENTIAL DATA ACCIDENTALLY
'IT WORKS BY CLEARING THE WINDOWS CLIPBOARD ENTIRELY
Option Explicit
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function EmptyClipboard Lib "user32" () As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Function ClearClipboard()
OpenClipboard (0&)
EmptyClipboard
CloseClipboard
End Function
'TO CALL THE CODE, JUST PUT THE FUNCTION NAME WHEREVER YOU NEED IT IN A MACRO:
Private Sub whatever()
blahblahblah
ClearClipboard
End Sub
Bookmarks