Question: Let's say I want to find the value of a cell in an Excel file. In VBA, I would do this:

```
Dim varValue As Variant
Dim wb As Workbook
Dim ws As Worksheet
Set wb = ThisWorkbook
Set ws = wb.Worksheets("Sheet1")
varValue = ws.Range("A1").Value

```

How do I set up a Visual Studio project so I can access and modify an Excel file in C# rather than in VBA?

What references might I need to add?

Does the file need to be open in order to work with it?

Answer: 
I wrote my own, fairly simple class to extract data from an Excel spreadsheet via C#. You need to include:

```
using Microsoft.Office.Interop;

```

Then you can do something like this to get started:

```
Excel.Application excel;
Excel.Workbook workbook;
Excel.Worksheet worksheet;
Excel.Sheets sheets;
Excel.Range range;

excel = new Microsoft.Office.Interop.Excel.Application();
workbook = excel.Workbooks.Open(workbookName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
sheets = workbook.Worksheets;
...

```
You have to used Microsoft.Office.Interop.Excel.
You'll need to use COM Interop. [Here's](http://msdn.microsoft.com/en-us/library/ms173186(VS.80).aspx) a detailed tutorial about how it's done.