Forum Discussion

KB1's avatar
Champion Level 2
2 years ago

Comparing Word field exchange to testcomplate value

I'm busy with creating a automated test to compare the field exchange values of a word document to text on a website. There I'm stuck and don't know how to make testcomplete open the word document...
  • rraghvani's avatar
    2 years ago

    I've just provided example code of opening a word document (document not provided); display number of paragraphs and output the first paragraph. It should be enough to get you started.


    A better version of the example code,

    function Test4()
        var word = getActiveXObject("Word.Application");
        word.Visible = true;
        var paragraphs = word.ActiveDocument.Paragraphs;
        for (var i = 1; i <= paragraphs.Count; i++) {

     which outputs all paragraphs. 

  • rraghvani's avatar
    2 years ago

    If the document structure is always the same, but the content is different. Then instead of having paragraphs output to log, you can store each paragraph into an array, which you can then use afterward e.g. to compare date, select fields etc.


    You need to define your data structure, and decide which values you intent to use, operation to perform etc. if applicable.