How to disable copy/paste in Word 2003

R

Raymond

Hi,

I am working on a word 2003 file and try to disable the copy/paste features
(I mainly concern about the copy feature at this moment). I found the
following coding in Web but found that it does not work.

I think the problem is caused by there is no "OnKey" for Application object.

Does anyone know how to do this task?

Please help.

Thanks in advance,
Raymond

Sub ToggleCutCopyAndPaste(Allow As Boolean)
'Activate/deactivate cut, copy, paste and pastespecial menu items
Call EnableMenuItem(21, Allow) ' cut
Call EnableMenuItem(19, Allow) ' copy
Call EnableMenuItem(22, Allow) ' paste
Call EnableMenuItem(755, Allow) ' pastespecial

'Activate/deactivate drag and drop ability
Application.CellDragAndDrop = Allow

'Activate/deactivate cut, copy, paste and pastespecial shortcut keys
With Application
Select Case Allow
Case Is = False
.OnKey "^c", "CutCopyPasteDisabled"
.OnKey "^v", "CutCopyPasteDisabled"
.OnKey "^x", "CutCopyPasteDisabled"
.OnKey "+{DEL}", "CutCopyPasteDisabled"
.OnKey "^{INSERT}", "CutCopyPasteDisabled"
Case Is = True
.OnKey "^c"
.OnKey "^v"
.OnKey "^x"
.OnKey "+{DEL}"
.OnKey "^{INSERT}"
End Select
End With
End Sub
 
T

Tony Jollans

Your immediate problem is that the code you have posted looks as though it
is for Excel, not Word.

Your longer term problem is that you cannot absolutely disable Copy and
Paste functionality - all you can do is prevent casual copying by ordinary
users. If that is sufficient for your needs you can best do it by creating
VBA procedures called EditCopy, EditCut, EditPaste, and EditPasteSpecial to
trap the respective actions.
 
R

Raymond

Thanks, your information is very useful.

Tony Jollans said:
Your immediate problem is that the code you have posted looks as though it
is for Excel, not Word.

Your longer term problem is that you cannot absolutely disable Copy and
Paste functionality - all you can do is prevent casual copying by ordinary
users. If that is sufficient for your needs you can best do it by creating
VBA procedures called EditCopy, EditCut, EditPaste, and EditPasteSpecial to
trap the respective actions.

--
Enjoy,
Tony

www.WordArticles.com
 
G

Graham Mayor

Whatever you do with vba, you do of course have the problem of forcing users
to run the vba code in order to implement it and thankfully you have no way
of doing that or Word would be unusable.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
F

fumei via OfficeKB.com

Hi Graham, what do you mean by:

"Whatever you do with vba, you do of course have the problem of forcing users

to run the vba code in order to implement it"

If you write:

Sub EditCopy()
Msgbox "Copy is disabled."
End Sub

and put that in a module in a document, all copy attempts will execute THAT
EditCopy procedure. It overwrites the native procedure. You do not have to
force the user to run it. It will run whenever a copy is done in that
document.

Of course, as Tony mentions, this is not exactly hard to run around by anyone
with moderately honed skills.

Graham said:
Whatever you do with vba, you do of course have the problem of forcing users
to run the vba code in order to implement it and thankfully you have no way
of doing that or Word would be unusable.
Thanks, your information is very useful.
[quoted text clipped - 58 lines]
 
J

Jay Freedman

But if you put any macro code in a document, it's subject to the user's
macro security setting -- the macro may be silently disabled, or the user
may be asked whether to enable or disable it. Only users whose security
level is Low will automatically enable the macro. If you sign the code with
a certificate, the user will be asked on first use whether to accept the
certificate, which they can refuse. Graham is right on this point.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
Hi Graham, what do you mean by:

"Whatever you do with vba, you do of course have the problem of
forcing users to run the vba code in order to implement it"

If you write:

Sub EditCopy()
Msgbox "Copy is disabled."
End Sub

and put that in a module in a document, all copy attempts will
execute THAT EditCopy procedure. It overwrites the native
procedure. You do not have to force the user to run it. It will run
whenever a copy is done in that document.

Of course, as Tony mentions, this is not exactly hard to run around
by anyone with moderately honed skills.

Graham said:
Whatever you do with vba, you do of course have the problem of
forcing users to run the vba code in order to implement it and
thankfully you have no way of doing that or Word would be unusable.
Thanks, your information is very useful.
[quoted text clipped - 58 lines]
End With
End Sub
 

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