-1

I am running a coded UI automation test, to test a winforms application. during the test the automation press a button that opens an excel file that contains a data.

how can i access this excel file and save it (i want to save it by using Microsoft.Office.Interop.Excel.Application). when i start my automation test i already open new instance of excel , this excel will be used to save data from the test and i close it only it the end of my test.

i tried to use

app = (Excel.Application)Marshal.GetActiveObject("Excel.Application");

with no luck

David Pilkington
  • 13,297
  • 3
  • 39
  • 67
avishaiy
  • 17
  • 1
  • You said "i already open new instance of excel" well keep a reference of that excel object and ask it to save.. – BugFinder Jan 04 '18 at 08:14
  • i did that but it saved me an empty excel file and not the file i wanted to save. – avishaiy Jan 04 '18 at 08:27
  • just to clarify , the excel i opened and the excel that opened during the automation test are two different instances. if i look at Task Manager i see two different process of excel. – avishaiy Jan 04 '18 at 08:28

1 Answers1

0

There was a similar question. The solution is based on searching all window handlers and then getting Excel.Application for all excel windows. Then you can choose the one you need and get access to its workbooks.

Alex Butenko
  • 3,554
  • 3
  • 36
  • 54