Automation Microsoft Word 2013

Ask general questions here.
Flash05
Posts: 12
Joined: Tue Jan 28, 2014 8:27 am

Automation Microsoft Word 2013

Post by Flash05 » Tue Jul 22, 2014 1:07 pm

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
Attachments
microsoft_word_2013.rxsnp
(110.47 KiB) Downloaded 170 times

User avatar
Support Team
Site Admin
Site Admin
Posts: 12172
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Automation Microsoft Word 2013

Post by Support Team » Fri Jul 25, 2014 3:04 pm

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)

User avatar
Support Team
Site Admin
Site Admin
Posts: 12172
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Automation Microsoft Word 2013

Post by Support Team » Wed Aug 27, 2014 3:43 pm

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)

bewiss
Posts: 16
Joined: Mon Feb 24, 2014 3:11 pm

Re: Automation Microsoft Word 2013

Post by bewiss » Tue Nov 11, 2014 2:46 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12172
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Automation Microsoft Word 2013

Post by Support Team » Wed Nov 12, 2014 1:12 pm

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)
Attachments
AutomationMicrosoftWord2013.zip
(119.33 KiB) Downloaded 206 times

bewiss
Posts: 16
Joined: Mon Feb 24, 2014 3:11 pm

Re: Automation Microsoft Word 2013

Post by bewiss » Mon Nov 17, 2014 8:28 am

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12172
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Automation Microsoft Word 2013

Post by Support Team » Thu Nov 20, 2014 1:58 pm

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)

bewiss
Posts: 16
Joined: Mon Feb 24, 2014 3:11 pm

Re: Automation Microsoft Word 2013

Post by bewiss » Sat Nov 22, 2014 4:42 pm

Hi Markus,

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