Use Excel files

  • Thread starter Thread starter Maileen
  • Start date Start date
M

Maileen

Hi,

I'm new to VB.NET and i have a little trouble with a small task
regarding use of Excel files.

My VB application should be able to open an Excel file, extract some
data, create another Excel file, create inside this new Excel file some
table and write extracted data there.

Nothing special...
However, i'm not able to use Excel library in my application.
I open Project -> Add reference -> Com -> Microsoft Excel 11.0 ...
(version 2003).

but when i use a simple example delivered with MSDN Library, it doesn't
work.

Does somebody have a working example just for me, to know if i include
well the library and to see the first steps of using this library command ?

thanks a lot,
Maileen
 
Yes i did and everything is ok.

here is my code :

Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

xlApp = CType(CreateObject("Excel.Application"), Excel.Application)
xlBook = CType(xlApp.Workbooks.Add, Excel.Workbook)
xlSheet = CType(xlBook.Worksheets(1), Excel.Worksheet)
' Place some text in the second row of the sheet.
xlSheet.Cells(2, 2) = "This is column B row 2"
' Show the sheet.
xlSheet.Application.Visible = True
' Save the sheet to C:\Test.xls directory.
xlSheet.SaveAs("C:\Test.xls")
' Optionally, you can call xlApp.Quit to close the work sheet.

this code is from MSDN help shipped with VS.NET 2003.

and i have as error message :
Audit_HWSW\Main.vb(138): Type 'Excel.Application' is not defined.

why ?
thx

Maileen
 
On my workstation I have 'Excel 2002 sp3' and my choice of component after installing the Office XP PIAs are (in the ADD ref / Com dialog):
1) Microsoft Excel 10.0 Object Library:

This will add 2 references: - Excel
- Microsoft.Office.Core

I must then use in code:

Dim X as Microsoft.Office.Interop.Excel.ApplicationClass

2) Microsoft Excel 5.0 Object Library:

This will add 1 reference: - Excel

I must then use in code:

Dim X as Excel.Application

Hi,

I'm new to VB.NET and i have a little trouble with a small task
regarding use of Excel files.

My VB application should be able to open an Excel file, extract some
data, create another Excel file, create inside this new Excel file some
table and write extracted data there.

Nothing special...
However, i'm not able to use Excel library in my application.
I open Project -> Add reference -> Com -> Microsoft Excel 11.0 ...
(version 2003).

but when i use a simple example delivered with MSDN Library, it doesn't
work.

Does somebody have a working example just for me, to know if i include
well the library and to see the first steps of using this library command ?

thanks a lot,
Maileen

User submitted from AEWNET (http://www.aewnet.com/)
 
On my workstation I have 'Excel 2002 sp3' and my choice of component after installing the Office XP PIAs are (in the ADD ref / Com dialog):
1) Microsoft Excel 10.0 Object Library:

This will add 2 references: - Excel
- Microsoft.Office.Core

I must then use in code:

Dim X as Microsoft.Office.Interop.Excel.ApplicationClass

2) Microsoft Excel 5.0 Object Library:

This will add 1 reference: - Excel

I must then use in code:

Dim X as Excel.Application


Hi,

I'm new to VB.NET and i have a little trouble with a small task
regarding use of Excel files.

My VB application should be able to open an Excel file, extract some
data, create another Excel file, create inside this new Excel file some
table and write extracted data there.

Nothing special...
However, i'm not able to use Excel library in my application.
I open Project -> Add reference -> Com -> Microsoft Excel 11.0 ...
(version 2003).

but when i use a simple example delivered with MSDN Library, it doesn't
work.

Does somebody have a working example just for me, to know if i include
well the library and to see the first steps of using this library command ?

thanks a lot,
Maileen

User submitted from AEWNET (http://www.aewnet.com/)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top