Forum: ...automation-microsoft-word-2013-t6550
Forum: ...automating-outlook-t1239
Ranorex website: help/latest/technology-instrumentation/testing-of-legacy-applications
I'm working with Windows 10 Enterprise, Ranorex 8.1.1 and Microsoft Word 2010. My objective is to find all the words in a document (Microsoft Word) that fulfill a specific format, which is: red and underlined or red and strike-through. See some examples in the picture I've attached.
First of all, I've tried to perform it by means of Ranorex Spy, adding class name to GPI capture list. However, Spy can't detect every word, it seems to detect some kind of text blocks whose pattern is unknown for me. Please, check the Ranorex Spy snapshot and compare it the Word document appearance that I've attached. As well as not detecting word by word, I can't see the properties involving underlined and strike-through, I just can see the color property. Has Ranorex got something to perform that?
My alternative has been to use some code in C# adapted to Microsoft, like explained in msdn.microsoft.com/en-us/library/kw65a0we.aspx and docs.microsoft.com/en-us/dotnet/csharp/programming-guide/interop/how-to-access-office-onterop-objects
I've managed to do researches by words, although not by color, underlined or strike-through properties. For the color research:
Word.Range auxrng = myDocument.Content; auxrng.Find.ClearFormatting(); auxrng.Find.Forward = true; auxrng.Find.Font.ColorIndex=Word.WdColorIndex.wdRed; //red color search. auxrng.Select(); // It is selecting the whole previous range, no distinction for the first red word auxrng.Find.Execute(""); auxrng.Find.Font.Underline=Word.WdUnderline.wdUnderlineSingle; auxrng.Select(); /it is selecting the whole previous range again auxrng.Find.Execute("");Before this code, I had written previous code to communicate Ranorex and Microsoft Word, no problems with that.
Word.Application wordApp = new Word.ApplicationClass(); Word.Document myDocument = wordApp.Documents.Open(wordComparedFilePath); wordApp.Visible = true;Even, as said, I've managed to define ranges starting by a specific searched word and ending with another word.
Regarding the strike-through words, I haven't found a code for searching them, just this: auxrng.Find.Font.Underline.StrikeThrough
I'm afraid this method returns a boolean but does not modify the range.
I would appreciate very much if someone could help me on this. If you need more files or information, ask me