vb.net Export To Excel, reference question

lauriemc

Freshman
Joined
Feb 2, 2007
Messages
26
I am trying to do an Export to Excel using vb.net in a Windows Application, AND, I realize there are many good threads already here on the topic.

BUt I have a problem. I have added the Excel reference from COM, the Excel 11 Object Library, I can see it in my Solution Explorer, but I am still getting an error on my line:

Dim excelApp As New excel.application

with the wavy error line under excel.application

It's like it's not recognizing the reference. I have also tried an Imports and Inherits just for the heck of it, but still am not having any luck.

Help! I need to break through this first step.... :(
 
it's been a while, but we had to write something to export to excel. when I say we, I mean I had nothing to do with it, I tasked it out and let someone else handle it. ;-) but here's the important stuff in VB 2003

hope this helps as a starting point

Visual Basic:
Imports System.IO
Imports Microsoft.Office.Interop
Imports System.Runtime.InteropServices

...


    Dim oXl As New Excel.Application
    Dim oWb As Excel.Workbook
    Dim oWs As Excel.Worksheet
    
    Dim fl As FileInfo = New FileInfo(sbPath.ToString)
    If fl.Exists = True Then Kill(sbPath.ToString)
    
    oXl = New Excel.Application
    oWb = oXl.Workbooks.Add(sbPath.ToString)
    
    ...
    
    wkIndex = 1
    oWs = oWb.Worksheets(wkIndex) 'which worksheet in the workbook
    
    ...
    
    oWs.Cells(rowIndex, colIndex) = value
    
    
    ...
    
    oWb.SaveAs(sbPath.ToString)
    
    ...
 
Back
Top