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: 
You **do not** have to use interop.

You simply need a reference to...

```
System.Data.OleDb

```

Define a connection string as you would any other data source:

```
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=YourPath;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";";

```

And add some code to query your database:

```
OleDbConnection objConnection = new OleDbConnection();
string strSQL = "SELECT * FROM [YourTable]";
objConnection = new OleDbConnection(connectionString);
objConnection.Open();
OleDbCommand cmd = new OleDbCommand(strSQL, objConnection);
DataTable dt = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(dt);

```

...Then enumerate through your data rows.
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.