[RESOLVED] working with Excel from VB2005..
Hi. I am getting errors when writing the codes below:
Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim oRng As Excel.Range
' Start Excel and get Application object.
oXL = CreateObject("Excel.Application")
oXL.Visible = True
' Get a new workbook.
oWB = oXL.Workbooks.Add
oSheet = oWB.ActiveSheet
errors: Type Excel.Application is not defined.
the same errors for the other 3 Dim statements.
This is only a small part of the code which I got from microsoft MSDN site.
I had included the MS Excel library 12.0 Object libray reference.
I have done this in VB6 without any problem.
What is wrong with the above Dims? I am using VB2005 and MS Excel 2007.
Thank you.
Re: working with Excel from VB2005..
Just ran the following under VS2005 and worked fine
Code:
Dim oXL As Microsoft.Office.Interop.Excel.Application
Dim oWB As Microsoft.Office.Interop.Excel.Workbook
Dim oSheet As Microsoft.Office.Interop.Excel.Worksheet
Dim oRng As Microsoft.Office.Interop.Excel.Range
' Start Excel and get Application object.
oXL = CType(CreateObject("Excel.Application"), _
Microsoft.Office.Interop.Excel.Application)
oXL.Visible = True
' Get a new workbook.
oWB = oXL.Workbooks.Add
oSheet = CType(oWB.ActiveSheet, _
Microsoft.Office.Interop.Excel.Worksheet)
Re: working with Excel from VB2005..
Simple working demo attached in 2005 project. Personally I use Aspose cells for Excel work.