lauriemc Posted June 29, 2007 Posted June 29, 2007 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.... :( Quote
alreadyused Posted June 29, 2007 Posted June 29, 2007 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 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) ... Quote
lauriemc Posted June 29, 2007 Author Posted June 29, 2007 Your first three lines were the most important lines, as I was missing 2 of them. Thanks:o Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.