Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine which FormField has the focus in a Word document

Status
Not open for further replies.

rtoews

Programmer
Oct 11, 2001
7
US
Although the MS Windows 2000 Visual Basic Help appears to be a useful source of information, I'm not seeing how to determine which field within a document has the focus. All I need is the field name, so that I can use it as an index for ActiveDocument.FormFields() to set the value.

My object is to be able to use a function key to place a predetermined (and often-typed) string of text in the currently active form field. The text won't be on the clipboard, so I can't just paste it in.

Thanks,

Rick
 
have you tried SendKeys?

Code:
SendKeys "this is a test."

I tried this (Office 97 only however) and it works.
however, it took about 2-3 seconds for the text to appear.

then again the slow-down might have been due to my MP3 player
 
Thanks for the response, although that's not really what I'm after. Placing a value in a form field isn't the problem. One way I can do that is:

ActiveDocument.FormFields("fieldname").Result = "Some text"

The problem I need to solve is determining the field that has focus, so that the name of the field can be used as the index for the FormFields array (instead of "fieldname", as in the above example).

Each text field in a form has a numerical index, and it also has a name (bookmark). It's difficult for me to imagine that Word Basic can't detect, at any time, which field has the focus and return the field name. Still, I have not been able to find any indication in the documentation I have of how this might be done.

Any other suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top