0

I am developing and Accessibility enabled Application. Application Concept its a Natural Language Processing NLP applications. When a user write something in the word document it will show the suggestions. For this I need to have the last 100 Characters in the Current Text Control(Text Pattern).

UIA(User Interface Automation) Framework provides access to the every TextPattern Control which is accessibilty Enabled. However when I try to access the current word document window text pane ( Editor) and text inside it does not provide me access. Former version of UIA is MSAA.

I need to access the current text editor pane(not the ribbion bar, scrools else) in the microsoft window 2007 or later document.

i have to access this thing through the UIA other option is OFFICE WORD Interop. OFFICE WORD Interop does not provide me the control over the user activity.

kindly suggest any sample code using UIA to get text inside the word editor document

Scenario required:

Open a word document and write something in the Text area. Now I need to access that text concurrently as my intelligent app will get the current text previous to max.100 characters and minimum 2 to show suggestions.

Please find the screencast link below the samples I made working to give you idea.

Only the Text Extraction part is not working right in MS-Word.

Check this Video I required Same functionality required from the MS word USING UIA

Waiting for your quick reply..

Alfergon
  • 5,463
  • 6
  • 36
  • 56
faheem.si
  • 21
  • 2
  • You can't get word's document using any Windows API, only by using Word/Office COM/Automation API. see here for a quote from a Microsoft guy: http://social.msdn.microsoft.com/Forums/vstudio/en-US/09f7752d-e4cd-4bb1-80a9-a560b290129a/get-text-from-wwg-class – Simon Mourier Jul 26 '13 at 14:29
  • And there is an example here that's using the Word API. It's combined with a little automation bootstrap (AccessibleObjectFromWindow), but it's the Word API that eventually talks to Word: http://stackoverflow.com/questions/2203968/how-to-access-microsoft-word-existing-instance-using-late-binding – Simon Mourier Jul 26 '13 at 14:45

1 Answers1

1

Word 2007 doesn't have UI Automation support (much less TextPattern). You'll have to use the Word API.

Eric Brown
  • 13,774
  • 7
  • 30
  • 71
  • But if i use WORD API that requires the COM library for Office. Mean my products application assume the Microsoft Office Component will be available on the end-user machine. i don`t want to use the WORD 2007 – faheem.si Jul 29 '13 at 12:02
  • Please Suggest My Application requires 'When an end user type something in the word document it will be showing the word suggestions while typing. ' for that i needed to get last 100 characters to get or read text from the same carrot position. – faheem.si Jul 29 '13 at 12:15
  • Well, I *suppose* you could use Text Services Framework to extract the text, but doing so is *extremely* difficult. I spent 2 years working full time to get a text service that worked reliably with Word. – Eric Brown Jul 29 '13 at 14:10
  • i am using Office Add-in for word can you help me on that to listen the key press event inside the word and extracting text. http://stackoverflow.com/questions/17992516/vsto-ms-word-2010-plugin – faheem.si Aug 01 '13 at 11:17
  • Based on your comment from 2013 above, I assume Word has support for the Text Services Framework? Thank you. – Sabuncu Apr 30 '21 at 12:01
  • @Sabuncu - Yes, most versions of Word (>2003 or so) have support for Text Services Framework. I **really** wouldn't recommend it, though. Text Services Framework is built to create global solutions (Input Method Editors), not local solutions. More recent versions of Word (>2010 or so) do support UIA and TextPattern; it's only the older versions of Word (IIRC, 2007 was the last) that don't support UIA. – Eric Brown Apr 30 '21 at 13:20
  • Thank you for responding. Just to clarify: you do not object to an approach that uses UIA then? Thanks again. – Sabuncu Apr 30 '21 at 13:46
  • @Sabuncu I love UIA. It's my preferred approach for a number of scenarios. – Eric Brown May 01 '21 at 14:22
  • Same here! I feel like UIA is an undiscovered gem. Thank you so much for confirming. Regards. – Sabuncu May 01 '21 at 14:33