A question on VB.NET


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: A question on VB.NET

  1. #1
    Join Date
    Jun 2007
    Posts
    1

    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.

  2. #2
    Join Date
    Mar 2005
    Location
    Los Angeles, Calif. AKA: Gangsta Yoda™
    Posts
    455
    Did you install the PIAs for Office? Link in my signature for more on Office Interop.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer code questions via PMs.
    Microsoft MVP 2006-2009
    Office Development FAQ (VBA, VB6, VB.NET, C#)
    Software Engineer MCP (VB6 & .NET)
    Reps & Rating PostsVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6Outlook Global Address List

Similar Threads

  1. Question about WebBrowser VB.NET
    By Mansur in forum .NET
    Replies: 2
    Last Post: 07-06-2006, 06:53 AM
  2. VB.Net Class Design Question
    By jrothlander in forum .NET
    Replies: 3
    Last Post: 07-01-2006, 10:55 PM
  3. Why I like VB.NET
    By Tom Cabanski in forum .NET
    Replies: 74
    Last Post: 03-14-2001, 04:30 PM
  4. Is VB.Not still a BEGINNERS' language?
    By Mark Burns in forum .NET
    Replies: 164
    Last Post: 03-13-2001, 01:43 PM
  5. VB.NET: 3 points of view
    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center