Forum Discussion

Peleg's avatar
Peleg
New Contributor
15 years ago

Identifying MS WinWord objects using TC object browser

Hi,



I'm trying to test out product, which is a MS WinWord plugin, and I can't seem to identify the WinWord document's objects using TC object browser.



The whole text area in the document is presented as a single object, and none of the properties retrieves the information I need about the document (e.g - the current text in the document, not to mention more specific attributes).



Is there a way to retrieve information from a WinWord document, like the text in the document, and performing actions on the document such as clicking on a specific word (without using coordinates)?



Thanks in advance,

Peleg.

5 Replies

  • sbkeenan's avatar
    sbkeenan
    Frequent Contributor
    Hi Peleg



    I've never used TestComplete with Microsoft Word, but having had a brief look just now, I have come up with the following :



    Aliases.Sys.Process("WINWORD").Form("Document1 -").Window("_WwF", "", 1).Panel("Document1").Panel("Microsoft Word Document").NativeObject.Document.Content



    You'll excuse the fact that nothing has been mapped, hence the long winded text above, but, essentially, the Content property shows the text within my test document, as shown in the attached image.



    I have also seen other properties, e.g.Sentence, etc. that you may find useful.  However, I haven't yet had time to look at any methods for searching the document text for a specific instance of text.  If I do, I'll post what I find.



    Hope this has been of some use!!



    Regards

    Stephen.




  • Hi Peleg and Stephen,



    You can use the Word Object model and work with the application via COM:

    Set WordApp = Sys.OleObject("Word.Application")

    WordApp.Visible = True

    WordApp.Documents.Open("C:\Document.docx")

    Log.Message(WordApp.ActiveDocument.Content)


    searching the document text for a specific instance of text

     

    See the following MSDN Library article to learn how to do this.
  • Peleg's avatar
    Peleg
    New Contributor
    Hi Stephen and David,



    Thank you very much for your help.



    Stephen - I searched for the property you pointed out, but when I tried to view it, it was blank... Screenshot attached.

    David - Your solution worked well, but I don't understand why Stephen's property is blank on my platform. Any ideas?



    Thanks,

    Peleg.
  • Peleg's avatar
    Peleg
    New Contributor
    I enabled the hidden members and now it works nicely.

    Thanks!