

We have a JSFiddle that shows copying and pasting (tested in Firefox, Safari, Chrome, and IE9+). If you just want to retrieve text (CF_TEXT) from the clipboard, a single line of code is enough.I actually have done a lot of work on this, and just wrote a nice blog post describing how we did it in detail at Lucidchart (as a disclaimer, I work at Lucidchart). This means you do not need to explicitly create an instance of that class but can just reference this class as Clipboard in your code. The class module Clipboard hat its Attribute VB_PredeclaredId set to True. Then open the VBA-Editor with your application, Use the “File” -> “Import File” menu to import the Clipboard.cls file into your application. To integrate this class into your application, download the Clipboard-ZIP-Archive and unpack it. It is a VBA class module that can be used in any VBA enabled application.

This download not limited to Microsoft Access. I guess, I will add that whenever I find the time. – It cannot write any data to the clipboard yet. It can retrieve plain text from the clipboard, ANSI and Unicode (untested!), and the file content of any file on the clipboard (tested only with text). Capabilitiesĭue to time constraints, this sample is current very limited only. Nevertheless, I managed to create a basic VBA Clipboard class that nicely wraps this complexity under its hood. The Windows Clipboard API proved to be way more complex than I originally anticipated. Despite being busy otherwise I couldn’t resist to hack a small sample class together, which would retrieve the file content of a file from the clipboard using the GetClipboardData function from the Windows API. However, none of those samples work when you don’t have the text directly in the clipboard but rather a file containing text.

Well, there are couple of samples available to get Text from the clipboard using the Windows API. I recently encountered a question on a forum where someone copied a text file from his email inbox onto the clipboard and needed to retrieve this file or its content in Access VBA. By Philipp Stiefel, originally published September 3rd, 2019, last updated September 3rd, 2019
