Excel VBA - How do I clear the clipboard on another workbook in another application?

Since workbook wb belongs to another application instance, you should use

wb.Application.CutCopyMode = False

instead

Application.CutCopyMode = False

where wb.Application returns applications instance which workbook wb belongs to.


What I do is just copy any blank cell in my ActiveWorkbook once I have pasted the values that I copied earlier and I don't need them any more - and this replaces the large data in the Clipboard with an empty string (comparatively nothing) and allows me to close the workbook when I need to.

I understand this is rather a workaround, but it works all the time.

Another Solution

What you should try is to get the MSForms DataObject and try to put it in clipboard

Dim clipboard As MSForms.DataObject
Set clipboard = New MSForms.DataObject

and then clear it as following:

clipboard.Clear

And if this doesn't work, you can always set the clipboard text to empty

clipboard.SetText ""
clipboard.PutInClipboard

The Application.CutCopyMode = False did not work for me to clear the buffer or stop getting an error when trying ActiveSheet. Paste errorActiveSheet. Paste error

To clear a large buffer, which is producing an ActiveSheet.Paste error for example is to simply copy an empty cell, for example Range("A1").Copy, where cell A1 would be empty or very small. This will then make the buffer really small! Easy fix! Maybe not precisely correct, but it is functionally correct.

Tags:

Excel

Vba