View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.general
Jonathan West Jonathan West is offline
external usenet poster
 
Posts: 13
Default Clear Office Clipboard from VBA?


"theLuggage" wrote in message
...
I found some code on the web to manipulate the Windows clipboard using
windows API calls.

Is there a way to manipulate the MS Office clipboard?

Here's the scenario. I've got some code that parses through a Word
document
and copies all the tables and images from the Word document into an Excel
Workbook. The tables all work fine, but the images are sometimes
duplicated.
Instead of getting image 1 and then image 2, I get two copies of image 1.

Even though I clear the clipboard (using the Windows API calls) before I
copy the figure, sometimes I still get the duplicate.

I ran my code with the Office clipboard command bar showing and it looks
like the Office clipboard doesn't get cleared at all. To show the Office
clipboard, I'm just choosing View--Toolbars--Clipboard.

Is there a way to clear the Office clipboard?

Thanks in advance for the help!

(Forgive the cross-post. I'm not sure where to post the question.)


There isn't a direct way to clear the set of Office clipboards in VBA, but
what you can to is execute the button on the Clipboard toolbar that achieves
this. A bit of experimentation shows that the button's ID code is 3634, so
the following line of code will do the trick

CommandBars.FindControl(ID:=3634).Execute


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org