-
A question on VB.NET
Hi to all,
I want to run excel solver in a VB.NET routine.
I have installed VSTO but when I want to compile my program (I have written it in VB.NET language in a software, it is not in the Visual Studio 2005 main Program) it finds an error: "Namespace or type 'Interop' for the Imports 'Microsoft.Office.Interop' cannot be found."
Do u know the reason?
The code for more information is this:
Imports Microsoft.Office.Interop
Imports System.Runtime.InteropServices
Private Sub bSolveExel_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles bSolveExcel.Click
Dim wb As Microsoft.Office.Interop.Excel.Workbook
Dim ExSheet As Microsoft.Office.Interop.Excel.Worksheet
Dim result as Double
Try
wb = ExApp.Workbooks.Open("E:\Excel-Sheet.xls")
ExApp.Run("SOLVER.XLA!Auto_Open")
ExApp.DisplayAlerts = False
ExApp.Visible = False
wb.Activate()
ExSheet = ExApp.Worksheets("Table1")
ExSheet.Activate()
.
' Code to save parameters in Excel Sheet
CType(ExSheet.Cells.Item(3, 2), Excel.Range).Value2 = TextBox.Text
.
' Code to copy result to the variables
result = CType(ExSheet.Cells.Item(9, 2), Excel.Range).Value2
ExApp.DisplayAlerts = False
ExApp.Quit()
Catch ex As COMException
MessageBox.Show("Error accessing Excel: " + ex.ToString())
Catch ex As Exception
MessageBox.Show("Error: " + ex.ToString())
End Try
End Sub
After that I wrote some Macros in the Excel Sheet to start the calculation
Does any body have an idea?
Thanks in advance.
-
Did you install the PIAs for Office? Link in my signature for more on Office Interop.
Similar Threads
-
Replies: 2
Last Post: 07-06-2006, 05:53 AM
-
By jrothlander in forum .NET
Replies: 3
Last Post: 07-01-2006, 09:55 PM
-
By Tom Cabanski in forum .NET
Replies: 74
Last Post: 03-14-2001, 04:30 PM
-
By Mark Burns in forum .NET
Replies: 164
Last Post: 03-13-2001, 01:43 PM
-
By David Kroll in forum .NET
Replies: 33
Last Post: 02-13-2001, 11:23 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|