rajbay

I have created a solution in Visual Studio 2005 with several VSTO Excel projects and a windows application. Depending on the user selection, I would like to call a VSTO Excel project. How do I call the VSTO project from the winform application

Re: Visual Studio Tools for Office Calling a VSTO Excel project from a WinForm

Dennis Wallentin

Hi,

The following sample can hopefully get You started:

Imports System
Imports System.Runtime.InteropServices
Imports Excel = Microsoft.Office.Interop.Excel

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim xlApp As Excel.Application = Marshal.GetActiveObject("Excel.Application")
Dim Counter As Object

For Counter = 1 To xlApp.COMAddIns.Count
If xlApp.COMAddIns.Item(Counter).Description = "VSTOCase" Then
xlApp.COMAddIns.Item(Counter).Connect = True
End If
Next Counter

xlApp = Nothing
Me.Close()

End Sub
End Class