How to Identify Clipboard Data Types in Word VBA
Question details
The user is looking for a way to identify or enumerate the types of data formats currently stored in the system clipboard using Word VBA.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Attempting to inspect clipboard contents programmatically within a Word VBA macro to determine what format is available before pasting.
- Observed behavior
- Word VBA lacks comprehensive built-in methods to enumerate clipboard formats reliably, unlike standard Visual Basic, limiting native access mostly to text strings.
Before working with clipboard data in VBA, ensure you have enabled the 'Microsoft Forms 2.0 Object Library' in your VBA Editor references to access the DataObject class.
Use MSForms.DataObject for Text and Supported Formats
This is the most reliable VBA-native method for handling basic clipboard data types like text.
VBA does not have comprehensive built-in access to the operating system's clipboard, but you can manage basic text data using the DataObject. Since the clipboard can hold multiple formats simultaneously, DataObject is best used when you specifically need to verify or extract plain text.
Open the VBA Editor (ALT + F11), go to Tools > References, and check the box for 'Microsoft Forms 2.0 Object Library'.
In your VBA module, declare a new DataObject instance using the code: Dim clipboard As New MSForms.DataObject
Use the clipboard.GetFromClipboard method to command VBA to retrieve the current clipboard contents into your object.
Use the clipboard.GetFormat(1) method to check if the clipboard contains text data (format ID 1). It returns True if text is present, allowing you to paste safely.

Use Windows API Functions to Enumerate Formats
Bypass VBA's limitations by directly calling OS-level Windows API functions to identify the exact clipboard data formats.
Avoid Unreliable Methods Like SendKeys
Explains why the SendKeys command should not be used as a workaround for clipboard inspection.
Use WPS Office for Powerful Macro and VBA Support
WPS Office offers seamless compatibility with Microsoft Word documents and robust support for VBA macros. If you are developing macros or executing complex tasks, WPS provides a lightweight, highly compatible, and free alternative to streamline your workflow without sacrificing functionality.
- 1. Download WPS Office: Visit the official WPS website and download the free WPS Office installer.
- 2. Install the software: Run the setup file and follow the straightforward on-screen instructions to install.
- 3. Enable VBA support: Open WPS Writer, navigate to the Developer tools, and start writing or importing your existing macros immediately.

Frequently Asked Questions
Can I use Visual Basic clipboard methods in Word VBA?
No, standard Visual Basic (like VB.NET) has a different structure and deeper OS integration than VBA. Word VBA must rely on the more limited MSForms.DataObject or direct Windows API calls to interact with clipboard formats.
Why does my VBA code fail when pasting an image from the clipboard?
The native MSForms.DataObject only supports text formats. If the clipboard contains an image, bitmap, or complex rich formatting, VBA's native DataObject cannot process it directly without utilizing Windows API functions.
How do I handle multiple formats stored simultaneously in the clipboard?
The clipboard often holds the exact same copied data in multiple formats (e.g., HTML, plain text, RTF). You should use the clipboard.GetFormat method to check for your preferred format ID before calling the get or paste commands.
Is SendKeys a safe way to test clipboard contents?
No, SendKeys is generally considered highly unreliable because it depends entirely on active application focus and precise execution timing. It cannot inspect data types beforehand and may cause unexpected inputs in your documents.




