fionabolt
06-07-2007, 02:20 AM
Can anyone help. I have created a template that results in a document they is password protected where editing rights are restricted only to a certain style.
However, users could select all, copy the contents and paste them into another document and edit the elements they are not supposed to!
Therefore I am trying to disable the copy command on the Edit commandbar of the Menu bar. Do do this, I wrote the following:
Public Sub Document_New()
Call DisableCopy
End Sub
Public Sub DisableCopy()
Dim myControls As CommandBarControls
Dim nS As Boolean, tS As Boolean, dS As Boolean
Dim oCtrl As CommandBarControl
Dim aKey As KeyBinding
Dim myStr As String
'capture saved state
nS = NormalTemplate.Saved
tS = ActiveDocument.AttachedTemplate.Saved
dS = ActiveDocument.Saved
Rem--disable copy on toolbar
Customizati
Set myC For Each oCtrl In CommandBars.FindControls(ID:=19)
If oCtrl.Enabled = True Then
oCtrl.Enabled = False
End If
Next oCtrl
Rem--disable "CTL+C" copy
Customizati For Each aKey In KeysBoundTo(KeyCategory:=wdKeyCategoryCommand, _
Command:="EditCopy")
myStr = myStr & aKey.KeyString & vbCr
aKey.Disable
Next aKey
MsgBox myStr
'return to captured saved state
NormalTemplate.Saved = nS
ActiveDocument.AttachedTemplate.Saved = tS
ActiveDocument.Saved = dS
End Sub
But it doesnt work. What am I doing wrong?
Thanks
However, users could select all, copy the contents and paste them into another document and edit the elements they are not supposed to!
Therefore I am trying to disable the copy command on the Edit commandbar of the Menu bar. Do do this, I wrote the following:
Public Sub Document_New()
Call DisableCopy
End Sub
Public Sub DisableCopy()
Dim myControls As CommandBarControls
Dim nS As Boolean, tS As Boolean, dS As Boolean
Dim oCtrl As CommandBarControl
Dim aKey As KeyBinding
Dim myStr As String
'capture saved state
nS = NormalTemplate.Saved
tS = ActiveDocument.AttachedTemplate.Saved
dS = ActiveDocument.Saved
Rem--disable copy on toolbar
Customizati
Set myC For Each oCtrl In CommandBars.FindControls(ID:=19)
If oCtrl.Enabled = True Then
oCtrl.Enabled = False
End If
Next oCtrl
Rem--disable "CTL+C" copy
Customizati For Each aKey In KeysBoundTo(KeyCategory:=wdKeyCategoryCommand, _
Command:="EditCopy")
myStr = myStr & aKey.KeyString & vbCr
aKey.Disable
Next aKey
MsgBox myStr
'return to captured saved state
NormalTemplate.Saved = nS
ActiveDocument.AttachedTemplate.Saved = tS
ActiveDocument.Saved = dS
End Sub
But it doesnt work. What am I doing wrong?
Thanks