Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8319827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:26:38+00:00 2026-06-08T22:26:38+00:00

I have created an Excel Addin using the VSTO Template (VS2010, Excel2007). In the

  • 0

I have created an Excel Addin using the VSTO Template (VS2010, Excel2007).
In the Solution Explorer, I have a group called Excel, and under that a file called ExcelAddIn.cs. This has access to the active worksheet through code like

public partial class MyAddIn
{
    Excel.Worksheet activeWorksheet = (Excel.Worksheet)Application.Activesheet;
    Excel.Range firstRow = activeWorksheet.get_Range("A1",missing);
}

etc. This code works fine ie. I can get at the Excel model.

Rather than put all my processing code in this one class file however, I’d like to work on Excel worksheet data in another class file. I have created this file, but am unable to use any code like the above in it, ie. I cannot seem to access the Excel model from this file.
I’ve duplicated the ‘using Microsoft.Office.Tools.Excel’ references, but putting in a line like:

Excel.Worksheet activeWorksheet = (Excel.Worksheet)Application.Activesheet;

gives me a ‘The name ‘Application’ does not exist in the current context’ error.

Any ideas on what references/changes I need to make to get at the Excel model from this separate class file?

btw. The file that works refers to an ‘Excel.Application’ object for that first code line, the second separate file that doesn’t work is referring to ‘Microsoft.Office.Interop.Excel’ object.

Thanks
Pete

==== FOUND ANSWER ====
The way to get at your worksheets from other classes you add is to simply access

Globals.ThisAddIn.Application.ActiveSheet;

for example:

Excel.Worksheet ws = (Excel.Worksheet)Globals.ThisAddin.Application.ActiveSheet;

where ‘ThisAddIn’ is the name of the class your wizard created (you may have renamed it).

So, use Globals to get at your Excel objects outside the ThisAddin code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T22:26:40+00:00Added an answer on June 8, 2026 at 10:26 pm

    Your own answer here:

    The way to get at your worksheets from other classes you add is to simply access

    Globals.ThisAddIn.Application.ActiveSheet;
    

    for example:

    Excel.Worksheet ws = (Excel.Worksheet)Globals.ThisAddin.Application.ActiveSheet;
    

    where ‘ThisAddIn’ is the name of the class your wizard created (you may have renamed it).

    So, use Globals to get at your Excel objects outside the ThisAddin code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel VSTO AddIn that I moved up to Excel 2007/VS2010 last
I have a created an excel addin application in vb.net using vs2010.The application is
we have created a VSTO Excel workbook with VS2010, .NET 4.0. After we publish
I have created Excel Sheet using Java program. It works fine. My problem is,
I have created an Excel document using OpenXml SDK 2.0, now I have to
I have created a macro for excel which will pop up form that contains
I am using POI 3.8 to create Excel sheets using Java I have created
We have an application that is built with Excel as the front end using
I have a Excel addin that displays some structures on the worksheet. Users can
I have a pretty big web application that I created last year using ASP.NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.