# How to access an already opened Excel file in Mathematica?

This post 4594 shows how to open a existent Excel file with Mathematica. And this 6686886 shows how to do what I need, but in C#. This 12282310 is another related one.

How can I connect to a spreadsheet that is already open?

Using SE as my rubber duck to organize ideas worked just nice. I found the answer in NETLinkUserGuide.

To get current Excel session use GetActiveCOMObject instead of CreateCOMObject. Here is a code example.

Needs["NETLink"]
InstallNET[]
excel=GetActiveCOMObject["Excel.Application"]
worksheet=workbook@Worksheets["Sheet1"];
worksheet@Range["A1"]@Value="1, 2, 3 testing"


To get your active workbook use:

With[{$name=excel@ActiveWorkbook@Name}, workbook=excel@Workbooks[$name]
]


workbook=excel@Workbooks["MySpreadsheet.xlsx"];

PS: any tip to replace code injection using With` is welcome.