Results 1 to 15 of 15
  1. #1
    New Lounger
    Join Date
    Jul 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Protected Forms - Grayed out menu items (XP)

    I have a form created in word. It has two sections... one is protected and one is not. When I protect the document, my users are not able to access certain menu items... primarily "inserting text box or autoshape" or "formatting pictures". There are others that aren't available but those are the ones i am interested in. Microsoft's knowledge base mentions that this is the case, but it also mentions that "NOTE: It is possible to customize all of the menus, keyboard commands, and so forth, with AutoNew macros." I need to know how to do this... can anyone help????

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Protected Forms - Grayed out menu items (XP)

    Is this two different KB articles you're referring to, or just one? Could you point to article number or numbers? It's true you can customize all of Words menus and so forth, but it's very doubtful that you can use these customizations to get around the limitations which Word imposes on a document when you have one or more protected sections.

    Gary

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Protected Forms - Grayed out menu items (XP)

    I don't think AutoNew is going to help you, unless you can find a way to do it directly. For example, this doesn't work in Word 2000:
    <pre>Sub BypassProtection()
    If Selection.InlineShapes.Count > 0 Then
    'try to format picture
    Selection.InlineShapes(1).Select
    With CommandBars.FindControl(ID:=2327)
    .Enabled = True
    .Execute 'fails if any section is protected
    End With
    End If
    End Sub</pre>

    Can you post a link to the MSKB article?

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Protected Forms - Grayed out menu items (XP)

    With a bit more context, it is clear why this is in an article about protected documents
    <hr>NOTE: It is possible to customize all of the menus, keyboard commands, and so forth, with AutoNew macros. Also, add-in products (such as Microsoft Internet Explorer or Microsoft Bookshelf) modify menu choices.

    Customization may also produce the behavior described in the "Symptoms" section of this article.
    Workaround<hr>
    This is warning you that disabled menu commands may have multiple causes, one of these is that the document has been protected, another is that someone has intentionally disabled them using a Macro.

    StuartR

  5. #5
    New Lounger
    Join Date
    Jul 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protected Forms - Grayed out menu items (XP)

    Microsoft Knowledge Base Article - Q211333
    WD2000: Some Menu Commands Unavailable (Document Protection)

    Symptoms
    Under certain conditions, you may be unable to access all of the commands in Word, or you may be unable to move the insertion point to certain areas of the document.

    NOTE: Menu commands that are not available appear grayed or dimmed on the Word menus. Keyboard commands that edit or format text and graphics are also unavailable.

    Cause
    This problem occurs if document protection is enabled. The "More Information" section of this document lists commands that are unavailable when document protection is enabled.

    NOTE: It is possible to customize all of the menus, keyboard commands, and so forth, with AutoNew macros. Also, add-in products (such as Microsoft Internet Explorer or Microsoft Bookshelf) modify menu choices.

    Customization may also produce the behavior described in the "Symptoms" section of this article.

    Workaround (see MS page)

    Truncated -Mod.[/i]

  6. #6
    New Lounger
    Join Date
    Jul 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protected Forms - Grayed out menu items (XP)

    So, what you are saying then is.....

    That I cannot alter the menus in a protected form???

    I can't understand the reason for not allowing one to do things such as add a text box, or format a picture, especially in the unprotected section of the form....

  7. #7
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Protected Forms - Grayed out menu items (XP)

    I am definitely not saying that you cannot alter the menus in a protected form. I was simply trying to clarify why the knowledge base article you mentioned referred to customised menu commands and forms in the same article.

    I just tried creating a simple document with two sections, one protected and the other not protected. I then created a simple Macro...
    <pre>Public Sub TestMenuChange()
    CommandBars("Tools").Controls.Add Type:=msoControlButton, ID:=2334, Before:=22
    End Sub
    </pre>

    This adds the "Next misspelling" command to the Tools menu. This Macro was created whilst the document was still protected.

    I then ran the Macro and noted that the entry was added to the menu.

    The problem you have is that changing the menu commands will almost certainly not allow you to do the other things you want to. The restriction on what you can do in a protected form is not imposed by word's menus, it is (I think) in the underlying object model. If the menus won't let you do something then a macro won't let you do it either.

    If you really need to do things to protected forms that word won't let you, the only effective method is for your Macro to Unprotect the form, make the change and protect it again.

    regards,

    StuartR

  8. #8
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protected Forms - Grayed out menu items (XP)

    <hr>So, what you are saying then is.....That I cannot alter the menus in a protected form???<hr>
    Yes, but may be a way to do what you need to do. When a user tabs to a field in a protected template, you can have that field run an entry (runs when the user enters that form field) or exit macro (runs when that user exits the form field). However, it depends exactly what you're trying to do. In general, the macro:
    1. Unprotects the document for forms
    2. Performs an action
    3. Reprotects the document for forms, making sure not to reset the fields (which would erase the contents).

    For example, you could have the last field in the document have an exit macro that would spellcheck the form. You can see such a macro here

  9. #9
    New Lounger
    Join Date
    Jul 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protected Forms - Grayed out menu items (XP)

    So then... If i have a template with two sections. Section one is a protected table with user filled-in entry boxes. Section two is an unprotected section for the user to free-type in text. Should i set it so that as the user enters section two, it unprotects the document. And if the user exits section two (back into section 1) it re-protects the document????

    What script would i use to do this??

  10. #10
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protected Forms - Grayed out menu items (XP)

    I am not a VBA expert, so I don't know if what you propose is possible. I kind of doubt it only because I've never seen it done, & yet many people are frustrated that they can't use certain tools in a protected form. What I was thinking of was more along the lines of unprotecting the document when you entered a particular form field, inserting a particular picture ( or performing some other action), & then reprotecting the document for forms without resetting the field. The actual code would depend upon what specifically you were trying to do.

  11. #11
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Protected Forms - Grayed out menu items (XP)

    Word will be working a lot harder if it has to check every mouseup and keyboard navigation to determine what section the insertion point is now in. Could bog it down pretty seriously.

    Perhaps if you start at the beginning by telling us the nature of the form, there might be a different solution that allows you the degree of user convenience and control that you are trying to achieve in the protected portion of the document, while leaving the entire thing unprotected.

  12. #12
    New Lounger
    Join Date
    Jul 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Protected Forms - Grayed out menu items (XP)

    Okay... here is how the form is laid out...

    At the top of the form is a table. The user fills in boxes such as name, address, etc. These are input boxes and the user tabs from one box to the next. This table is in its own section (section-1), which is protected. That way, the user will not typeover any of the heading for the boxes which they are to fill in, nor will they mess up any of the formatting. Section-1 (the table) takes up approximately 1/4 of the first page.

    When the user tabs into the final box of section-1, I have code which automatically makes the cursor jump to section-2. Section-2 is on the same page and is not protected. It is simply blank paper for the user to freely write a narrative of text in. When the user gets to the end of the page, section two just automatically continues on for page 2, 3, 4, etc.

    The entire form is only made of the two sections.

    Part of the narrative will often require the user to input pictures. This they can do now. But what they cannot do is access the picture properties, or put in a text box or call-out to add labels to the picture. Those options are grayed out.

    Now, I could tell the users to make sure their forms toolbar is open, and click the unprotect icon every time they want to edit the pictures... but I know that most of the users will screw it up!

    So what I was thinking was... save the template so that it is protected upon being opened. That way, when the user opens the template and starts filling it out, the table portion will be protected. When the user tabs into the last field, the cursor will jump to the unprotected section-2. I should maybe add a line of code to the code that makes the cursor jump. The added code might unprotect the form... since the user is now in section-2 anyway. The important thing, though, is to make sure that if the user leaves section-2, and click back anywhere in section-2, that the form be protected again (without losing any of the inputed information).

    Does that seem possible, probable, or efficient to anyone????

  13. #13
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Protected Forms - Grayed out menu items (XP)

    I think data loss is a possibility under that scenario, but then again, I'm a klutz with forms.

    Depending on your users' formatting needs, you might be able to supply a few of the missing items using a macro. For example, this will work while a document is protected for forms:

    <pre>Sub ChgPicFormat()
    If Selection.InlineShapes.Count = 0 Then
    MsgBox "Select a picture and try again."
    End If
    'work directly with the picture properties
    Dim shpTarget As InlineShape
    Set shpTarget = Selection.InlineShapes(1)
    With shpTarget
    .Height = 0.9 * .Height
    .Width = 0.9 * .Width
    .Borders.Enable = wdLineStyleDouble
    End With
    End Sub</pre>

    However, Selection.CreateTextBox doesn't work. Hmmm... it's inconvenient, but the user can create a blank document, create the TextBox, and then copy/paste it (with the surrounding paragraphs) into the unprotected section of the protected document. Not very convenient. I hope you get some better suggestions!

  14. #14
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Protected Forms - Grayed out menu items (XP)

    On further thought, I think there is a way to unprotect a document briefly, do something, then reprotect without losing the data. There have been several threads on the Word and/or VB/VBA boards about how to spell check form fields that requires something like that. Although I never studied the code, you might see something in there that would give you confidence. Then, you could supply a menu or toolbar of the missing functions, and the macros could briefly unprotect the document, run the native function, then reprotect before exiting the macro. Again, I know almost nothing about forms, so if it doesn't work, I wouldn't be suprised.

  15. #15
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Protected Forms - Grayed out menu items (XP)

    This definitely does work.

    For example a Macro to create a text box might look like this...
    <pre>Sub AddTextBox()
    ActiveDocument.Unprotect Password:="Secret"
    ActiveDocument.Shapes.AddTextBox msoTextOrientationHorizontal, _
    Left:=50, Top:=75, Width:=100, Height:=80, Anchor:=Selection
    ActiveDocument.Protect wdAllowOnlyFormFields, NoReset, "Secret"
    End Sub
    </pre>

    (I assume that you have already taken care of <font color=blue>ActiveDocument.Sections(2).ProtectedFor Forms = False</font color=blue>)

    StuartR

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •