2

I'm running a macro on a word document.

After doing a Selection.Copy and running on, while debugging, I want to be able to see what was actually copied, and if it was mistakenly replaced.

Is there a way to "watch" Windows' clipboard?

JNF
  • 3,696
  • 3
  • 31
  • 64

2 Answers2

3

I found a way. At the beginning of my code:

Dim obj As New DataObject
obj.GetFromClipboard

I needed to reference Microsoft Forms 2.0 Object Library to have the "DataObject". At first I couldn't find it on the list - had to browse for FM20.dll.

The second line could be typed on need in immediate window, instead of writing it in the code. I found it easier this way.

Then, in the watch window, I put obj.GetText as a watch expression and voilà!

JNF
  • 3,696
  • 3
  • 31
  • 64
1

clipbrd.exe is the Windows clipboard viewer.

assylias
  • 321,522
  • 82
  • 660
  • 783