PDA

View Full Version : Focus in ContentControl



stringy
02-18-2009, 09:32 PM
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.

I tried this after updating the second ContentControl:


If Not (Selection.InRange(RngToCount)) Then
RngToCount.Select
Selection.HomeKey Unit:=wdLine
ActiveDocument.cont
End If

The selection happened as expected, but even though my cursor was in the ContentControl text, and clicking moved it, typing didn't do anything.

What am I missing?

stringy
02-19-2009, 07:42 AM
Oops, ignore the partial line "ActiveDocument.cont"