Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't clear office clipboard with VBA

I am using a function to copy a bunch of pictures out of an access database and store them on to the disk. However, this function uses the office clipboard and the clipboard fills up after about 150 records and crashes the program. Here is how I am clearing the clipboard

Private Declare Function apiOpenClipboard Lib "user32" Alias "OpenClipboard" (ByVal hwnd As Long) As Long
Private Declare Function apiEmptyClipboard Lib "user32" Alias "EmptyClipboard" () As Long
Private Declare Function apiCloseClipboard Lib "user32" Alias "CloseClipboard" () As Long

Sub EmptyClipboard()
    Call apiOpenClipboard(0&)
    Call apiEmptyClipboard
    Call apiCloseClipboard
End Sub

Anyone know how to more effectively clear the clipboard

like image 904
DasPete Avatar asked Nov 12 '22 13:11

DasPete


1 Answers

The functions you are using refer to the windows clipboard. This is different to the Office Clipboard

The only code I've found to clear that clipboard is Application.CommandBars("Clipboard").Controls(4).Execute, but as I have the office clipboard disabled (and, apparently, no way of enabling it), I can't see if that is the actual solution

like image 200
SeanC Avatar answered Nov 15 '22 06:11

SeanC