Can anyone give me a easy way of setting the protect/unprotect document
control in the tools menu to prevent it being used with specific documents i
create. I know i can use the enable true/false but how can i specify this
specific control without having to scroll through all the controls. I know it
has a specific control ID can I use this to select it if so how??
cheers
fred
Doug Robbins - Word MVP - 09 Nov 2006 06:08 GMT
Create a macro in the template from which the documents are created with the
name of ToolsProtectUnprotectDocument containing the following code:
Msgbox "The facility to change the protection status of this document has
been disabled."

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Can anyone give me a easy way of setting the protect/unprotect document
> control in the tools menu to prevent it being used with specific documents
[quoted text clipped - 7 lines]
>
> fred
Fred Kruger - 09 Nov 2006 06:38 GMT
Doug
What is the could please you have only sent the message box wording.
Fred
> Create a macro in the template from which the documents are created with the
> name of ToolsProtectUnprotectDocument containing the following code:
[quoted text clipped - 13 lines]
> >
> > fred
Jezebel - 09 Nov 2006 06:43 GMT
Read Doug's post again.
> Doug
>
[quoted text clipped - 23 lines]
>> >
>> > fred
Doug Robbins - Word MVP - 09 Nov 2006 06:45 GMT
Sub ToolsProtectUnprotectDocument()
Msgbox "The facility to change the protection status of this document has
been disabled."
End Sub

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Doug
>
[quoted text clipped - 23 lines]
>> >
>> > fred
Fred Kruger - 09 Nov 2006 08:00 GMT
Doug
perhaps its me thats no explained myself right.....
what is the vba code to select a specific id of a control and then set the
enable value to false rather than looking for the name of the control.
i.e the protect document button has an id no of 336 how do i use this to
always select that specific button and set the.enable function to false.
Because if the document is unprotected the name tag is protect document if
the document is protected it is unprotect document but the id no never
changes.
Or is it me that just cant see what you have sent.
Thanks for bearing with me on this.
Fred
> Sub ToolsProtectUnprotectDocument()
>
[quoted text clipped - 30 lines]
> >> >
> >> > fred
Doug Robbins - Word MVP - 09 Nov 2006 08:18 GMT
I think it is you. If you put the macro that I gave you into the template,
the user will not be able to change the protection status of the document;
if it is not protected, they will not be able to protect it; if it is
protected, they will not be able to remove the protection.

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Doug
>
[quoted text clipped - 53 lines]
>> >> >
>> >> > fred
Norman Goetz - 09 Nov 2006 09:09 GMT
Is that your Realname ?? Afraid of
>Can anyone give me a easy way of setting the protect/unprotect document
>control in the tools menu to prevent it being used with specific documents i
>create. I know i can use the enable true/false but how can i specify this
>specific control without having to scroll through all the controls. I know it
>has a specific control ID can I use this to select it if so how??
Public Sub Protectable(ByVal bEnable As Boolean)
Dim cmdBARS As Office.CommandBars
Dim cmdCTR As Office.CommandBarControl
Dim myMenu As CommandBarPopup
Set cmdBARS = Application.CommandBars
'Perhaps you have to check for the right Item
Set myMenu = cmdBARS.ActiveMenuBar.Controls.Item(6)
'This is what you meant ?
Set cmdCTR = myMenu.CommandBar.FindControl(msoControlButton, 336)
cmdCTR.Enabled = bEnable
End Sub
HtH
Norman Goetz