Page 1 of 1

Automation Microsoft Word 2013

Posted: Tue Jul 22, 2014 1:07 pm
by Flash05
Hello,

in my testcase i tried to validate the content of tabels in microsoft word 2013.
But it was not possible to get the values out of the table? Do yo have any ideas
why?

I had a similar Problem in Microsoft Outlook 2013. Posted in the following Thread http://www.ranorex.com/forum/automating ... t1239.html

Thx

Re: Automation Microsoft Word 2013

Posted: Fri Jul 25, 2014 3:04 pm
by Support Team
Hi,

Thank you for the snapshot. It seems that this is the same problem as in Outlook 2013.

We will get back to you when we have found a possible solution.

Regards,
Markus (S)

Re: Automation Microsoft Word 2013

Posted: Wed Aug 27, 2014 3:43 pm
by Support Team
Hi Flash,

Unfortunately, not all Office applications are supported in the same manner.
In order to validate text elements in a Word 2013 document you could use the following workaround:

First of all you need to add the Mircrosoft.Office.Interop.Word reference from GAC to your Ranorex solution.

This will allow you to use the following code:
var document1 = repo.Document1Word.Document1;
var wordDocObj = document1.GetWordDocumentObject();
var words = wordDocObj.Words;
foreach(Word.Range word in words)
{
  Report.Info(word.Text);
}
One of my colleagues also posted a workaround in another topic. Therefore, please have a look at the following link: Automating Outlook

Regards,
Markus (S)

Re: Automation Microsoft Word 2013

Posted: Tue Nov 11, 2014 2:46 pm
by bewiss
Hi Markus,
I tried this one out but there is no way to intellisense a GetWordDocumentObject() out of my Word-Repo-Item.

- I added the reference from GAC to the project and did the usual "using Microsoft.Office.Interop.Word"
- my "document1" Repo-item is valid and holds the allocated Word instance. After that, typing "var wordDocObj = document1." gets out nothing from Interop.Word, no autocompletion for this.

Is there anything else to do?

Best regards
Bernd

Re: Automation Microsoft Word 2013

Posted: Wed Nov 12, 2014 1:12 pm
by Support Team
Hi Bernd,

In general there is nothing additional to do. I've added a small sample Ranorex Solution which should work as expected.

Please perform the following steps in order to run my test:
  • Create a Word document named Document1
  • Write some text in this document
  • Open the sample solution and hit the run button.
Please let me know if my solution works on your machine.

regards,
Markus (S)

Re: Automation Microsoft Word 2013

Posted: Mon Nov 17, 2014 8:28 am
by bewiss
Hi Markus,

thx for your example. I really appreciate your fast responce and your very helpfull replies :-)

So, perhaps there was kind of a misleading description from my side. Reading from a stored .doc with office.interop wasn't the problem for me. I can do that.

I thought of a way to get data from Word on the fly. Your first example you gave looked to me as the repo element holds a Word instance whereas I'm able to fire the office.interop at.
In my very case, SUT opens up (triggered from Ranorex) a Word within some expected content. Without saving this Word document I targeted to validate the content and close the Doc without saving.

Sorry for the additional work I gave your with your example!

Is there a way to get information from an opened Word on the fly propperly?

Best regards
Bernd

Re: Automation Microsoft Word 2013

Posted: Thu Nov 20, 2014 1:58 pm
by Support Team
Hi Bernd,
I’m unfortunately not exactly sure if I got your question correctly, but in general it should also be possible to read data from a non-stored Word document with my sample.
Therefore, just adapt the path to find the desired Word document.

If you are still facing issues, please contact us by mail at [email protected]

Regards,
Markus (S)

Re: Automation Microsoft Word 2013

Posted: Sat Nov 22, 2014 4:42 pm
by bewiss
Hi Markus,

of course your example works. I was a little out of it :roll:
Thx
Bernd