Navigating in a form with content controls - skips over content

L

Loulou

I've designed a form. It's several tables in a single document containing
content controls including text entry fields, drop-down lists & date
pickers. Once I activate the protection for forms-fill-in - I use the tab
key to get from one cell to the next. It does NOT stop at every field.
Once a drop down list or date picker control is accessed, it then skips all
"text" controls and only moves to the two other types of controls.

Also - Is there a way to control the direction that the tab key goes (ie
horizontal vs vertical) when navigating through the form.

Thanks for any help in this regard - especially the first problem.
 
J

Jay Freedman

First of all, form fields and document protection aren't supposed to mix
with content controls. If you have any form fields from the legacy forms,
replace them with the equivalent content controls. (It sounds like you
aren't using check boxes, but if you are, then see
http://gregmaxey.mvps.org/Custom_CC_Checkboxes.htm.)

Instead of applying forms protection through the Protect Document pane or
the Lock icon, do this:

- Select the content controls plus all text that should not be editable.
- Click the Group button on the Developer tab of the ribbon and choose Group
from the menu.

The content controls will operate as usual. The text grouped with it won't
be editable -- you can put the cursor in it, but any attempt to edit it or
format it will be refused, with a message on the status bar. You should be
able to tab from one content control to the next -- except that you can
never tab out of a Rich Text content control, which just inserts a tab at
the cursor location.

To control the order of movement through the content controls (not really
the direction, but the order on a per-control basis) requires macro
programming. There are various ways to do it. One way is to enter a number
in the Tag value in the Properties dialog of each control, so the first
control has a Tag of 1, the second control (wherever it is) has a Tag value
of 2, and so on. Then put this macro in the ThisDocument module of the
template (see http://www.gmayor.com/installing_macro.htm if needed):

Private Sub Document_ContentControlOnExit( _
ByVal CC As ContentControl, _
Cancel As Boolean)
Dim thisTag As String, nextTag As String
Dim srchCC As ContentControl, foundCC As ContentControl

thisTag = CC.Tag
If Len(thisTag) > 0 Then
If IsNumeric(thisTag) Then
nextTag = CStr(Val(thisTag) + 1)
For Each srchCC In ActiveDocument.ContentControls
If srchCC.Tag = nextTag Then
Set foundCC = srchCC
Exit For
End If
Next

If Not (foundCC Is Nothing) Then
foundCC.Range.Select
Selection.Collapse wdCollapseStart
End If
End If
End If
End Sub

This will force the cursor to go through the controls in the numerical order
of their Tag values. A drawback is that it completely removes the ability to
Shift+Tab in reverse order, or to use the mouse to try to go out of order.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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