clearing the office clipboard in vba

G

Guest

Is there a way to clear the office clipboard in vba, I'm running XP and Excel
2003?
 
G

Guest

There still are items in the clipboard after using applicaiton.cutcopymode =
false


If run application.displayclipboardwindow = true i can still see items in
the office clipboard
 
S

ste mac

Hi, try this, its one of Chips.. l use it all the time..

Public Sub ClearClipboard()
Dim MyDataObj As New DataObject
MyDataObj.SetText ""
MyDataObj.PutInClipboard
End Sub

seeya ste
 
G

Guest

When I try and run this code I receive a User-defined type not defined ERROR
how do I set MyDataObj in Excel2003
 
T

Tom Ogilvy

You need to have a reference to the msforms 2.0 library - the same one that
has the userform objects.
 
S

ste mac

Hi, sorry l don't know (l have 2k) perhaps you could give Chip a shout
or visit his website...anyone else?
 
M

Myrna Larson

I would go to the VB Editor, then F2 to open the object browser, and search
for DataObject to see which library contains this object. In XL2000 it's in
the MSForms library, and you may need to set a reference to its counterpart in
XL2003.
 
D

Dave Peterson

Try this to see if you can find it:

Insert a new (temporary) userform into your workbook's project.

Then look at tools|references and see if you see something new checked.

Then remove the Userform.
 
G

Guest

So I've got this compiling and running in Word under Office 2003, but it
doesn't clear the clipboard for me. I copy several items, show the clipboard,
see them. Then run this macro, and they remain there. Am I missing something?

Thanks!
 
G

Guest

I'm also looking for such a procedure or method. I'm calling Excel from
Access and I notice that the suggested code clears the Excel clipboard but
not the contents of the clipboard from Access...If I check the clipboard from
Excel, it is in fact cleared, but if I switch to Access the clipboard there
still has the contents. I need to clear both. Anyone have a suggestion on how
to do that?
 
G

Guest

This worked for me (fixed the User-defined type not defined ERROR). What's
interesting is that I couldn't find the library (Microsoft Forms 2.0 Object
Library) in my list of references, but once I added a form as Dave suggested
below, it appeared at the top of the list and was checked, and then after I
deleted the form it was still there and checked and my macro now works.

Thanks!

Keith
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top