excel.interop reference

Posted on 2012-08-21
Last Modified: 2012-08-24
Ok, I lost a reference.
500 points to the one who can find it.

my code lines are:
xlApp.Cells[rowIndex, i + 1].Interior.Color = ColorTranslator.ToOle(Color.Aqua);
xlApp.Cells[rowIndex, i + 1].NumberFormat = "@";

both Interior and NumberFormat were working yesterday, but now they are giving me the error:
Error      1      'object' does not contain a definition for 'Interior' and no extension method 'Interior' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)      C:\Users\Evan\documents\visual studio 2012\Projects\DAT2MSSQL2XLS\DAT2MSSQL2XLS\Classes\DAT2XLS.cs      64      46      DAT2MSSQL2XLS

I am using .NET 3.5

Here's my page references:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.IO;
using Excel = Microsoft.Office.Interop.Excel;
using System.Drawing;

Here's my project references:
I think I lost a reference somewhere, and I don't know which one.
The is Version 12.

Question by:Evan Cutler
    LVL 23

    Accepted Solution

    First thing to try would be removing Microsoft.Office.Interop.Excel from the project references and then add it again.

    LVL 19

    Expert Comment

    it could also have something to do with the object 'rowIndex'. does it have a value and if so, does it lead to a cell ?

    i would expect something like xlApp.xlWorkbook.xlWorksheet.Cells[...] instead of xlApp.Cells[...]
    LVL 9

    Author Closing Comment

    by:Evan Cutler
    That did it.
    Thanks.  I don't know what happened.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
    This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now