VBA Code to clear the Windows 10 64 bit clipboard

JeffGrant

Well-known Member
Joined
Apr 7, 2021
Messages
558
Office Version
  1. 365
Platform
  1. Windows
Hi All,

does anybody have vba code to clear the windows 10 64 bit clip board?

I stupidly continue to paste code from the clipboard that isn't correct and it mess up my formulas.

So I figure if I clear the clipboard at the end of the sub, then I cant mess it up :-)

I would like to make my sheets a little bit more fool proof, or in this case Jeff-proof.

There are few references around, but the examples out there are not designed for windows 10 64 bit and so they code fails.

I am not talking about the vba clipboard because that can be cleared with application.cutcopymode = false. I am specifically wanting to clear the windows 10 clipboard.

Thanks in advance

Jeff.
 
Clear Excel Clipboard ...

Application.CutCopyMode = False
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi Jonny,

To my understanding, and as you have said, Application.CutCopyMode = False, clears the Excel clipboard.

It does not clear the Windows clipboard.

Because Harvey is using Outlook and Teams, he will need to clear the Windows Clipboard to see if that prevents his issue.

Cheers
 
Upvote 0
Hi Jonny,

To my understanding, and as you have said, Application.CutCopyMode = False, clears the Excel clipboard.

It does not clear the Windows clipboard.

Because Harvey is using Outlook and Teams, he will need to clear the Windows Clipboard to see if that prevents his issue.

Cheers
That being said, I agree with @RoryA
 
Upvote 0
This is a bug with the DataObject on Windows 8 and later that occurs when file explorer is open. You should use API calls to put the text on the clipboard instead
 
Upvote 0
Hi Harvey.

This is what I use in VBA to clear the clipboard

VBA Code:
Sub ClearClipboard()
    OpenClipboard (0&)
    EmptyClipboard
    CloseClipboard
End Sub

cheers
One last question if you don't mind. Where do I put this code? In the UserForm of the CommandButton? A Module? A Class Module? Or "This Outlook Session"?

I have the following code to clear the text boxes:
VBA Code:
Private Sub CommandButton3_Click()
UserForm2.TextBox1.Value = ""
End Sub

I would like to apply your code to this button so that it clears my Textboxes and it clears the clipboard as well.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,307
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top