disabling/enabling a control on a menu

F

Fred Kruger

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
 
D

Doug Robbins - Word MVP

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."

--
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
 
F

Fred Kruger

Doug

What is the could please you have only sent the message box wording.

Fred
 
D

Doug Robbins - Word MVP

Sub ToolsProtectUnprotectDocument()

Msgbox "The facility to change the protection status of this document has
been disabled."

End Sub

--
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
 
F

Fred Kruger

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
 
D

Doug Robbins - Word MVP

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.

--
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
 
N

Norman Goetz

On Wed, 8 Nov 2006 09:31:02 -0800, Fred Kruger wrote:

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
 

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