How can I load VSTO project from Winform Application?

It may sound like a silly question: "How can I load Excel Workbook in VSTO from Winform Application "

I'd like to use VSTO for the statistical report on data. When I build and debug the workbook, it works fine; however, I'm having trouble loading the workbook from another application. Loading dll file with showdialog() only shows the class file associated to the excel project instead of entire VSTO project.

Please help~~~



Answer this question

How can I load VSTO project from Winform Application?

  • Stampede2

    In your WinForm app:

    1. Set a reference to the Excel PIA (Microsoft Excel 11.0 Object Model on the COM page of the References dialog box).

    2. If you want, add an Imports (or Using) statement for the Excel namespace:
    Imports Excel=Microsoft.Office.Interop.Excel

    3. The code to open the workbook looks something like this (in VB, obviously):

    Dim app As New Excel.Application
    Dim wbk As Excel.Workbook = app.Workbooks.Open("c:\mypath\MyWorkbook.xls")

    That's the barebones solution, anyway. You'll want to tweak depending on what you really want to do once the workbook is open.

    --jan

  • addexm

    well Jan,you hav used Com , i want to create a VSTO Word object, so i can pass it to some other class, perform some action, and then show it, just like we do in Com Word object, i did casting as well, but its not working, showing error at run time that it cant cast interop.word to VSTO.word,How can i do that plz hlep me



  • How can I load VSTO project from Winform Application?