Hi everyone,

I have created a Word 2007 form containing some text fields which works fine, except that sometimes the focus is not right.

For the text fields I used a ContentControl.
I also have a commandbutton which gets a range from the ContentControl, using a bookmark, eg:


ActiveDocument.Bookmarks("bk1").Range.ContentControls(1).Range

which then calculates the word count, and updates the text in a second ContentControl:
wordCount = RngToCount.ComputeStatistics(wdStatisticWords)
CtrlToUpdate.Range.Text = wordCount
This gets odd when I double click elsewhere in the protected form, and then press the button. Everything updates, but I can't edit the text in the first ContentControl anymore. Even though my cursor was in the ContentControl text, and clicking moved it, typing didn't do anything.

Eventually some combination of clicking in other controls and pressing the update button would get focus to work again, but I don't know why I'm losing it in the first place.

I tried this after updating the second ContentControl:


If Not (Selection.InRange(RngToCount)) Then
    RngToCount.Select
    Selection.HomeKey Unit:=wdLine
End If
The selection happened as expected, but the focus problem is still there if I had first double clicked some text outside the

control.

What am I missing?