locked
Problems creating an Excel Add-In with VSTO RRS feed

  • Question

  • I'm keen to write an Add-In for Excel using C#. I've followed this page:

     

    http://support.microsoft.com/kb/302901

     

    and it's been helpful. Alas it mentions nothing about early and late binding and appears to be late bound. I'd prefer early bound of course, far more elegant.

     

    I also want to be able to access the Excel application object and create sheets, populate ethem and so on. The only on-line pointers I've found reger to the use of:

     

    Globals.ThisAddin.Application

     

    for example:

     

    http://xldennis.wordpress.com/2007/01/09/creating-and-deploying-managed-com-add-ins-with-vsto-2005-se-part-iii/

     

    Alas I can't refer to Globals at all in combination withj the example above (KB 302901) juts fail to build in VS 2005 reporting:

     

    The name 'Globals' does not exist in the current context.

     

    What reference is required to gain acces to Globals or am misunderstanding the context of the advice xldennis offers for example. It certainly seems to me that Globals provides an early bound path somehow providing access to a ThisAddin object which contains an Application object and so on ... and yet, if I could get the application object latebound at all that might help or even work out how to create a workbook or worksheet in a latebound model somehow.

     

    I'm feeling a but lost and short of pointers alas.

     

    Cheers,

     

    Bernd.

     

     

     

    Monday, October 1, 2007 7:17 AM

Answers

  • Hi Bernd,

    Globals.ThisAddin.Application can be only used in VSTO Add-In, but it seems that you are working on a Com Shared Add-In, not a VSTO Add-In.

    The whole KB article is describing how to create a Shared Add-in. The Shared Add-in can be created in Visual Studio 2005, by the template of Other Project Types->Extensibility->Shared Add-in. The VSTO Add-in should be created by template of Visual C#->Office->2007 Add-ins->Excel Add-in

     

     

    Thanks

    Ji

     

    Wednesday, October 3, 2007 2:04 AM
  • To display an actions pane, you must be using an Excel Workbook or Excel Template project (available on the Office tab of the New Project dialog). There are two main project types in VSTO: document-level customizations (including Excel Workbook and Excel Template projects) and application-level add-ins (including Excel Add-in projects, which you appear to be using). For more information about the distinction between these project types, see http://msdn2.microsoft.com/en-us/library/hy7c6z9k(VS.80).aspx.

     

    Some features in VSTO are available in only document-level projects or application-level projects, but not both. The actions pane feature is one of these; actions panes are available only in document-level projects.

     

    Although there is a similar feature for add-ins, called custom task panes, this feature can only be used in add-in projects for the 2007 Microsoft Office system (custom task panes are not supported in earlier versions of Office).

     

    I hope this helps clarify,

    McLean Schofield

     

    Wednesday, October 3, 2007 6:38 PM
    Answerer

All replies

  • Hi Bernd,

    Globals.ThisAddin.Application can be only used in VSTO Add-In, but it seems that you are working on a Com Shared Add-In, not a VSTO Add-In.

    The whole KB article is describing how to create a Shared Add-in. The Shared Add-in can be created in Visual Studio 2005, by the template of Other Project Types->Extensibility->Shared Add-in. The VSTO Add-in should be created by template of Visual C#->Office->2007 Add-ins->Excel Add-in

     

     

    Thanks

    Ji

     

    Wednesday, October 3, 2007 2:04 AM
  • Ji,

    Thanks heaps. The distinction is now clear and I'm rolling. I'm indebted. It brings me to my next hitcht. I'm following this page now:

    http://msdn2.microsoft.com/en-us/library/e3zbk0hz(VS.80).aspx

    on which is described how to create a custom actions pane. This stumps me however:
    1. Open your Excel project in Visual Studio.

    2. On the Project menu, click Add New Item.

    3. In the Add New Item dialog box, select Actions Pane Control, name it HelloControl, and click Add.

    I'm using the stated prerequisites: Visual Studio Team System and Microsoft Office 2003

    yet no Actions Pane Control is available when I click Add New Item on the Project menu. I'm bamboozled again and googling hasn't helped. I installed "Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System" as a download and the project I created used the template "Visual C#/Office/2003 Add-ins/Excel Add-in".

    I see clues on-line that that there is confusion between the terms "task pane" and "actions pane" and that custom actions/task panes may be possible only with Office 2007, but no definitive evidence I've managed to trace yet. Odd.

    I wish I ran into fewer road blocks heare alas, but that's life, I'll plod on with out an actions pane and just use a form to do what I want.

    Cheers,

    Bernd.

    Wednesday, October 3, 2007 6:59 AM
  • To display an actions pane, you must be using an Excel Workbook or Excel Template project (available on the Office tab of the New Project dialog). There are two main project types in VSTO: document-level customizations (including Excel Workbook and Excel Template projects) and application-level add-ins (including Excel Add-in projects, which you appear to be using). For more information about the distinction between these project types, see http://msdn2.microsoft.com/en-us/library/hy7c6z9k(VS.80).aspx.

     

    Some features in VSTO are available in only document-level projects or application-level projects, but not both. The actions pane feature is one of these; actions panes are available only in document-level projects.

     

    Although there is a similar feature for add-ins, called custom task panes, this feature can only be used in add-in projects for the 2007 Microsoft Office system (custom task panes are not supported in earlier versions of Office).

     

    I hope this helps clarify,

    McLean Schofield

     

    Wednesday, October 3, 2007 6:38 PM
    Answerer