Exception while copying huge data to clipboard

UiPath throws exception while copying huge data to clipboard .

This issue is not with UiPath Application only, it is with all 32-bit applications. Applications call GlobalAlloc to allocate the memory for data to be stored on the clipboard and make it available to other applications. 
For 32-bit applications GlobalAlloc can allocate blocks up to 2 GB in size or up to the amount of virtual memory the PC has, whichever is less. The Windows clipboard does not impose any other size limits.

A workaround which has worked with other customers is using data in chunks. You can use a counter with loops and append the data wherever you are saving it. It could be Excel, word, notepad etc. This is a recommended way when you are dealing with large amount of data.

It doesn't always clear the Clipboard, so it is a best practice to clear the Clipboard after Get Clipboard activity is performed in a loop.

Please note, to use Clipboard class please do not forget to import namespace "System.Windows.Forms".

There can be many ways to clear clipboard, please find below few of them:

  • clear() : To use Clipboard.clear() method in UiPath please use it like below screenshot:

 

  • Set the clipboard text to empty using methods:
    SetText("")
    clipboard.PutInClipboard("")

 

  • Without using any predefined method Clipboard can we cleared by: Copy (Ctrl+c)->Get Clipboard -> Copy empty notepad, use this in loop. This will copy the black data which will clear existing data from Clip.