Capture Cut-Copy-Paste actions

S

sos00

Hi guys,
i gonna to capture Cut-Copy-Paste activities of user in Word application.
how can i do that ? i didn't found any built-in solution so i capture
clipboard items to do that. but i can't detect which user do a Copy or do a
Cut action, also Paste action won't be capture in this way...

thanks...
 
H

Helmut Weber

Hi,

you can overwrite almost any command, maybe all.

Examples:

Sub editcopy()
MsgBox "editcopy"
' if condition then
Selection.Copy
End Sub


Sub editcut()
MsgBox "editcut"
' if condition then
Selection.Cut
End Sub

Sub editpaste()
MsgBox "editpaste"
' if condition then
Selection.Paste
End Sub

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
S

sos00

Hi,
i don't want to do these actions and i know how to use Selection.Copy or
Selection.Paste.
i want to know how can i determine that user copy a text or paste a piece of
text in document !!

Thanx
 
H

Helmut Weber

Hi,

with a sub editpaste() in your code,
you can check, whether the user
hit [ctrl v] or used "paste" form the menu "edit".

Of course you don't need a messagebox.
You may each time editpaste is executed,
write time, username, etc. in a logfile and
thus register, how often a user pasted something.
You may even register, all that was pasted.

You may allow pasting only to certain users,
depending on the username, like

if Environ("Username") = "Weber" then
selection.paste
else
"No pasting allowed"
Endif

You may shut down Word after the 11th pasting...
and and and

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
S

sos00

Hi,
Thank u so much... i got it :)

but there is a problem, i want to capture these events in my application
that written in vb.
is it any solution to use of this sub(s) in vb or other languages ? (i.e
vb.net) ?
and one more thing, is it any reference abt these procedures ? i didn't see
any of them before...

Best regards,
 
H

Helmut Weber

Hi,
Thank u so much... i got it :)

but there is a problem, i want to capture these events in my application
that written in vb.
is it any solution to use of this sub(s) in vb or other languages ? (i.e
vb.net) ?

All I can say is, that I got a feeling that this should be possible.
But at the moment I can only think of workarounds,
like making editpaste in Word write a value into a file
and checking in a loop in vb the value there.
Still better would be to write a value somewhere into memory,
and having vb or .net checking the value in that part of the ram
in a loop.
So that you can take action as soon as there is a certain value.
But I never did that before.
and one more thing, is it any reference abt these procedures ?
i didn't see any of them before...

Have a look at:
Tools, customize, commands, all commands (US-Version)

There may be complications with localized versions of Word.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
S

sos00

Thanks again,
at the end, have these sub(s) any parameter or return values?

for example when i override InsertChart or InsertPicture; as soon as user
click
Insert-Picture menu , my code will be execute and the picture selector box
won't be appeare...
how can i say to Word to continue the action ?
 
H

Helmut Weber

Hi,

if it isn't a simple command like editpaste,
things get inscrutable.

Sub insertpicture()
MsgBox "insertpicture"
Dialogs(wdDialogInsertPicture).Show
End Sub

This is as far as I can help you.

You'll soon find out about the limitations,
when it comes to calling dialogs.

If wish, I knew better.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
C

Cindy M -WordMVP-

Hi Sos00,
Thank u so much... i got it :)

but there is a problem, i want to capture these events in my application
that written in vb.
is it any solution to use of this sub(s) in vb or other languages ? (i.e
vb.net) ?
and one more thing, is it any reference abt these procedures ? i didn't see
any of them before...
There's no really good way, as there aren't any events for these things.

closest you could get would be to use the procedures Helmut has described to
call back to your .NET app... as long as this is an Addin?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
S

sos00

Thank u very much Helmut
it's the same way that i thought abt that :)
thanks for ur help ...
 

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