Content Controls

M

Max

Is there a way to have the user move easily from one content control to
another?
In Word 2003, used Text Form Fields and could use F11 key, but not the same
in Word 2007.
Have looked in Help and KB - no results.
Used the Browse button to browse Fields, but did not work. Used Tab key, did
not work.
Please help!
 
J

Jay Freedman

Is there a way to have the user move easily from one content control to
another?
In Word 2003, used Text Form Fields and could use F11 key, but not the same
in Word 2007.
Have looked in Help and KB - no results.
Used the Browse button to browse Fields, but did not work. Used Tab key, did
not work.
Please help!

The Tab key will move between content controls EXCEPT when the cursor
is in a Rich Text content control where it's required to produce a tab
character, or a building block gallery content control.

It might be possible to program a Document_ContentControlOnExit macro
to move the cursor from a specific rich text content control to the
next content control when you mouse or arrow (but not tab) out. For
example, if the controls are given Tag values of RT1 (for rich text)
and PT1 (for plain text), this macro would do.

Private Sub Document_ContentControlOnExit(ByVal CCtrl As _
ContentControl, Cancel As Boolean)
Dim cc As ContentControl
If CCtrl.Tag = "RT1" Then
For Each cc In ActiveDocument.ContentControls
If cc.Tag = "PT1" Then
cc.Range.Select
Selection.Collapse wdCollapseStart
Exit For
End If
Next
End If
End Sub
 
M

Max

Jay,

Sorry, but the tab key does not work. Where do I hang that macro? There is
no place I can find to put an "On Exit" macro...
 
J

Jay Freedman

Hmm. The tab key works for me, on multiple computers. It's a mystery...

Put the macro into the ThisDocument module of the form document or template.
You'll have to save the file as a macro-enabled document (.docm) or template
(.dotm), otherwise the macro would be discarded during the save. And you'll
need to save it in a trusted location so the macro won't be disabled on
reopening (Office button > Word Options > Trust Center > Trust Center
Settings > Trusted Locations).

Content controls don't have any way to specify an "On Entry" or "On Exit"
macro like legacy form fields. Instead they have event handlers -- which is
what Document_ContentControlOnExit is, for the Exit event -- that fire
whenever the cursor enters or exits *any* content control. Then the code in
the handler has to figure out whether the control involved (passed in the
argument CCtrl) is one for which it should do something. My example uses the
control's Tag value to make that decision, but there are other things it
could look at, such as the Title or the ID value.
 

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