none
Tabbing order in checkbox content controls in Word 2013 and 2010 RRS feed

  • Question

  • I added a series of checkbox content controls to a Word2013 document, NOT a dialog box. When I click one of the checkboxes, the focus shifts to the SECOND checkbox in the series, NOT the NEXT checkbox.

    I added some Visual Basic msgboxes to the OnEnter and OnExit events in the document to display the Title and Tag of the ContentControl that is being entered or exited. This shows that the focus DOES shift the the next checkbox in the series but it exits the checkbox immediately and enters the next box, which is the second box after the box clicked. In other words, it appears the focus is moving correctly from one box to the next, BUT the focus does not remain in the next box but quickly moves out of it.

    I have tried the document in both Word 2013 and 2010, and the behavior is the same.

    Is this a bug, or do I need to add code to prevent this?

    Thanks,

    Van

    Wednesday, April 30, 2014 2:29 PM

All replies

  • Hi Van

    It sounds to me like you might have some code that's moving the focus. Or the content control is set to not allow editing...


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, April 30, 2014 4:44 PM
    Moderator
  • Thanks Cindy, but the content controls DO allow them to be edited. Clicking any of the checkbox content controls causes them to be checked or not appropriately.

    There is no code that changes the focus of these controls. In fact, when I delete ALL the code, the behavior is the same.

    In fact, I just created a simple document with 5 or 6 checkbox content controls in a row, AND the focus changes as one would expect, namely from one control to the next. SO, there is something in my original document that is causing the weird behavior. For now, I cannot figure out what it is.

    Van


    Wednesday, April 30, 2014 5:02 PM
  • Hi Van

    Could you put the original document up on OneDrive or something similar so that we can look at it?

    Note that, if no code is involved, then your question would be better asked in a non-programmer forum where you're more likely to find a number of people who have experience dealing with this. The MSDN forums focus on programming...

    http://answers.microsoft.com/en-us/office/forum/word


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, May 1, 2014 4:24 PM
    Moderator
  • Thanks Cindy,

    FYI, I started with a blank document and inserted just the checkbox content controls I needed. Then I checked it, and the focus moves as expected.

    Then I moved content from the original into the new document piecemeal. Then checked, and the focus moved as expected.

    Then I copied a command button from the original to the new document. When I checked the focus, it resorted to jumping to the second content control. There are other buttons in the document but before the first checkbox control. That is as far as I got.

    Will let you know if I find anything new,

    Van

    Thursday, May 1, 2014 6:07 PM
  • Do you have "protection for forms" switched on? This could be the same behaviour that was discussed here: http://social.msdn.microsoft.com/Forums/office/pt-BR/1905d0a4-cb2c-4d1e-8b4a-408d6ba3b05d/macro-isnt-executed-after-leaving-text-field?forum=worddev

    Peter Jamieson

    Friday, May 2, 2014 5:57 AM
  • Thanks Peter,

    I DO have protection for forms turned on. I believe it is necessary to avoid allowing the user to edit the form.

    In any event, I removed the legacy form elements that came after the series of content control checkboxes. I was able to then complete the form by using only content controls AFTER the checkboxes. Then the focus changes as expected.

    That worked to that form; however, I am working on another form, and I see the same behavior. THIS form is very complex. So I believe I will have to replace the content control checkboxes with legacy checkboxes.

    I must admit that I do not understand the purpose of content controls. The online Microsoft talks about using them to structure content but then shows examples about adding them to a document. They show no examples about actually using them.

    Van

    Tuesday, May 13, 2014 3:58 PM
  • With content controls, you're really supposed to select the form (text etc.) that they are in and use the Group option. Or you can manually create a Rich Text controls and put your other controls in there. The tabbing isn't as straightforward as with the legacy forms controls, but that does protect non-control text etc.

    i.e. there are "non-programming" ways to use content controls and I think this is why Cindy was pointing you to non-programming groups.

    > I must admit that I do not understand the purpose of content controls.

    I don't know precisely what Microsoft was originally aiming at with content controls, but they aren't just used for form-filling. They are also used for data insertion and replication (cf. Document Property fields and Document Variable fields) and have some behaviour that other approaches don't (e.g. automatic replication where the user does not even have to update any fields). A lot of the features are clearly aiming at corporates using SharePoint. But there are probably many use cases where the so-called "legacy" forms controls are still a better bet. For example, you can't use content controls-based forms on any version of Mac Word, but the "legacy" controls are at least similar, if not completely identical.


    Peter Jamieson

    Wednesday, May 14, 2014 9:05 AM
  • Van,

    Unless you need to support Mac users, I think content controls are well suited for forms, but they have no place in documents protected for filling in forms (i.e., mixed with legacy formfields or not).  See: http://gregmaxey.mvps.org/word_tip_pages/content_control_fillin_form.html and in particular the method for "No changes (Read Only).

    Personally I think the behavior of the focus shifting automatically anywhere (the next control or elsewhere) after checking a CC checkbox is both weird and undesirable and that won't happen using CCs in a document restricted with no changes.Best Regards,

    Greg

     


    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

    Wednesday, May 21, 2014 1:23 PM
  • Greg,

    Thanks for the information. I have looked at several of your articles, but the one on forms eluded me. The information on groups is good, because I had no idea what groups did, other than group things.

    My solution was to redesign the form a little. The legacy button at the end of the document was not needed. And I could replace the legacy radio buttons with a drop down list. Doing so returned the tabbing behavior to what the user expects. The client was overjoyed.

    HOWEVER, the client wanted more. The form displays several options that a salesman is to select for a client. Then the form is to be printed and sent to the client BUT without showing the unselected options. The customer is to see only what the customer wants.

    It has been suggested in other posts that it helps to surround content and controls with rich text controls. After much thought and playing around, I decided to do that and use that structure to programmatically change content to the font property of hidden, or not, whichever the case may be. When I needed to change the hidden property, I simply unlocked the contents of the appropriate rich text control, change the paragraphs to styles that included hidden fonts, and then lock the control. This works find except when I set the protections to filling in forms. Word then complains that I am trying to edit content in a protected portion of the document. As part of the testing, I left the rich text controls UNLOCKED and turned on filling forms protection. As one would expect, I could delete and insert text into the field, thus changing it. It appears that when the contents are unlocked, Word thinks it is OK to edit the text but no change a formatting style. This seems like a bug to me.

    In any event, but wrapping all the parts in rich text controls and locking their contents, I was able to provide the client with a protected form even while protection is off. The tabbing behavior is gone but hopefully does not matter.

    I believe many of the issues with content controls would be resolved if Microsoft had just exposed more events for the controls, such as onClick and onChange.

    I guess I could avoid content controls but they do offer features that I like, such as placeholder text (which you seem to dislike) and repeatable sections. I am working on another form in which repeatable sections places a major part.

    Van

    Wednesday, May 21, 2014 2:10 PM
  • Van,

    I don't dislike placeholder text, I simply dislike that MS has not provided a simply means to keep it from being printed in a finished document.

    The only method I use now for content control forms is the method described in the section "No changes (Read Only).  I have yet to find a situation that I can't make that method work.


    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm

    Wednesday, May 21, 2014 2:37 PM
  • Hi Van

    <<I believe many of the issues with content controls would be resolved if Microsoft had just exposed more events for the controls, such as onClick and onChange.>>

    Actually, these events are there, just not on the content controls. If you link the content controls to a Custom XML Part then the events you're looking for is provided by the ContentControlBeforeStoreUpdate event.


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, May 21, 2014 3:27 PM
    Moderator
  • Cindy,

    Personally, I think that event is very, very limited if you want to do anything with the document (e.g., formatting) vice the data and it still requires the user to exit the control in the case of rich or plain text controls. 

    Van, I posted and example using that event the other day here:
    http://www.msofficeforums.com/word-vba/21081-how-use-onchange-event-content-controls-word.html

    You can also look at: http://gregmaxey.mvps.org/word_tip_pages/content_control_custom_events.html

     


    Greg Maxey Please visit my website at: http://gregmaxey.mvps.org/word_tips.htm


    • Edited by Greg Maxey Wednesday, May 21, 2014 4:26 PM
    Wednesday, May 21, 2014 4:25 PM