473,412 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Use Excel files

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
Nov 21 '05 #1
4 2436
Hi Maileen!

"Maileen" schrieb
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.


What is the error message?

Do you have Primary Interop Assemblies for Office XP installed?

http://www.microsoft.com/downloads/d...4-01FEBA508E52

Cheers

Arne Janning
Nov 21 '05 #2
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


Arne Janning wrote:
Hi Maileen!

"Maileen" schrieb
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.

What is the error message?

Do you have Primary Interop Assemblies for Office XP installed?

http://www.microsoft.com/downloads/d...4-01FEBA508E52

Cheers

Arne Janning

Nov 21 '05 #3

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/)
Nov 21 '05 #4
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/)
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Rich | last post by:
Hi, I have a bunch of Excel reports that I would like to display on my company's intranet. The reports contain priviledged information, however. My plan was to have a page with a dropdown box...
0
by: Oci-One Kanubi | last post by:
Everything works fine in Access, but when I double-click on the resultant Excel files the first one opens correctly, but subsequent ones, and any other Excel files I try to open, fail to display at...
0
by: Jack | last post by:
Windows 2K Pro Access/Excel 2003 Hi there, I have a large number of password protected Excel Workbooks. The files are protected by code that runs when the workbook opens. The code asks the...
1
by: richard | last post by:
Hi, I am trying to manipulate data to and from Excel S'sheets from Asp.Net pages. I saw an article using - Imports Excel = Microsoft.Office.Interop.Excel Does anyone know what I need to...
3
by: Boris Condarco | last post by:
Hi gurus, I'm using excel 2000 to show data that comes from datagrid. The problem is that for any reason the asp.net application maintains the excel open, even though, i do close it. Besides,...
0
by: Rich Wallace | last post by:
Hello all, Looking for suggestions and tips if possible. I have an application running on a file server that utilizes the FileSystemWatcher to trap when any Excel files are saved by a user. I...
18
by: gonzlobo | last post by:
No, I don't want to destroy them (funny how the word 'decimate' has changed definition over the years) :). We have a data acquisition program that saves its output to Excel's ..xls format....
1
by: chrspta | last post by:
I am new to Visual basic. I need a program using VB6 that converts txt files to excel file.Description is in the below: The form should have the Drive list, Dir list, file list and cmdConvert...
0
by: Jon Delano | last post by:
Hello All I am working a on web application created in Visual Studio 2005 VB. It has to do some work with Excel files, so I created a DLL in VS2005. My development machine is XP SP3. When my...
5
by: Doogie | last post by:
Can anoyne tell me why this VBScript will create the file to Excel just fine, but the Excel file will not open up? I am saving it as a xlsx file instead of an xls one and I have the new version of...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.