clearing clipboard item through vb(a) code

R

Rob

Hi, i'm looking for code to clear one (office) clipboard item out of many.
And is it possible to do a copy-paste action without filling the (office)
clipboard?

thx.

Rob
 
K

Karl E. Peterson

Rob said:
Hi, i'm looking for code to clear one (office) clipboard item out of
many. And is it possible to do a copy-paste action without filling
the (office) clipboard?

This may not help, but to clear the *Windows* clipboard in VBA, you need to use the
Win32 API:

Public Function Clear() As Boolean
' Clear the clipboard of all content. (Same
' behavior as standard VB Clipboard object.)
If OpenClipboard(0&) Then
Clear = CBool(EmptyClipboard)
Call CloseClipboard
End If
End Function

I'm not aware of object model support for the Office clipboard? If you'd like to
recreate the Clipboard object exposed by standard VB, though, the code above comes
from http://vb.mvps.org/samples/ClipEx

Sorry... Karl
 
M

Martin Seelhofer

Hi Rob
Hi, i'm looking for code to clear one (office) clipboard item out of many.
And is it possible to do a copy-paste action without filling the (office)
clipboard?

Maybe, the MSForms library's DataObject is something for you:

' clear the clipboard:
Dim dobj As New DataObject
dobj.SetText ""
dobj.PutInClipboard

' set some text:
Dim dobj As New DataObject
dobj.SetText "Hello World!"
dobj.PutInClipboard

' get clipboards contents:
Dim dobj As New DataObject
dobj.GetFromClipboard
MsgBox dobj.GetText

Note that you need to add a reference to the MSForms library (which
is automatically generated for you, if you already added a UserForm
to your project)...


Cheers,
Martin
 
K

Karl E. Peterson

Hi Martin --
Maybe, the MSForms library's DataObject is something for you:

' clear the clipboard:
Dim dobj As New DataObject
dobj.SetText ""
dobj.PutInClipboard

' set some text:
Dim dobj As New DataObject
dobj.SetText "Hello World!"
dobj.PutInClipboard

' get clipboards contents:
Dim dobj As New DataObject
dobj.GetFromClipboard
MsgBox dobj.GetText

Note that you need to add a reference to the MSForms library (which
is automatically generated for you, if you already added a UserForm
to your project)...

I looked at that, too, but didn't see any method to remove items from the clipboard
with that?

THanks... Karl
 
J

Jonathan West

Rob said:
Hi, i'm looking for code to clear one (office) clipboard item out of many.
And is it possible to do a copy-paste action without filling the (office)
clipboard?

Hi Rob,

The other answers have been dealing with the Windows Clipboard.

As far as I'm aware it is not possible to selectively clear an individual
entry on the Clipboard toolbar, you can only clear the whole lot. This is
done with the following line of code

CommandBars.FindControl(ID:=3634).Execute

And, no, it isn't possible so far as I know to do a copy without filling an
entry on the clipboard toolbar.
 
R

Rob

Jonathan West said:
Hi Rob,

The other answers have been dealing with the Windows Clipboard.

As far as I'm aware it is not possible to selectively clear an individual
entry on the Clipboard toolbar, you can only clear the whole lot. This is
done with the following line of code

CommandBars.FindControl(ID:=3634).Execute

And, no, it isn't possible so far as I know to do a copy without filling an
entry on the clipboard toolbar.

Hi Jonathan,

when i executes the code:

ActiveDocument.CommandBars.FindControl(ID:=3634).Execute

in the direct window of the Word2003 VBA i get rte 91, how can i use this
code?

this code (new to me) to clear all items can be usefull for me....!

(it's a pity that you can not clear one item after another....., when you
can, copy past without use of the clipboard wasn't a problem anymore....)

thx.

Rob
 
J

Jonathan West

Rob said:
Hi Jonathan,

when i executes the code:

ActiveDocument.CommandBars.FindControl(ID:=3634).Execute

in the direct window of the Word2003 VBA i get rte 91, how can i use this
code?

this code (new to me) to clear all items can be usefull for me....!

(it's a pity that you can not clear one item after another....., when you
can, copy past without use of the clipboard wasn't a problem anymore....)

Hi Rob,

Grrrr. Microsoft changed the feature between Word 2K and Word 2003. And it
doesn't work on 2003. Brilliant. Just brilliant. And I haven't been able to
find anything else that does work instead.

One of these days Microsoft will have to learn that if these kinds of
features are going to be useful in a corporate environment, they have to be
programmable and *stay* programmable!

Sorry to have misled you.
 

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