Excel VBA Clear Clipboard
Clearing the clipboard in Excel VBA only requires a single line of code:
Application.CutCopyMode = False
However, this is different from the standard Windows clipboard. To clear the Windows clipboard you can use the EmptyClipboard Function. Copy and paste the code below into a code module and run Sub TestClipboardClear to clear the Windows clipboard.
Option Explicit Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long Public Declare Function EmptyClipboard Lib "user32" () As Long Public Declare Function CloseClipboard Lib "user32" () As Long Public Function ClearClipboard() OpenClipboard (0&) EmptyClipboard CloseClipboard End Function Sub TestClipboardClear() Call ClearClipboard End Sub
VBA Coding Made EasyStop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!