• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

how do insert excell ws into vb project ?

please tell me how do i insert excell ws into the vb project ?

what control / components do i need insert ?

for your information i just want to insert abc.xls file only not the excell.exe. so my user can manipulate or using that ws as he/she like.

and that ws can be link with the data control.

i hope you understand it.

u got to answer the 3 question above.

ok.
thanks

0
JOHNHO
Asked:
JOHNHO
  • 2
  • 2
1 Solution
 
TimCotteeCommented:
The simple answer to the first two questions, is to add an ole container control to the form.

Create a new project and add the ole control to the form, select create from file and point to abc.xls.

Run the project. When you double-click the control (you can do this programmatically as well). It will open a cut-down representation of excel in the current form which gives you full excel functionality. You can also use the excel automation object to programatically control the worksheet.

The third part of the question is contradictory to the first two because if you open the worksheet in this way there is no need to control it using the data control.

0
 
pmcgivernCommented:
Place an MS Data Bound Grid Control from under the Project/Components menu option onto your form.  Then place a Data control onto your form.

Set the Data controls Connect property to Excel 8.0.

Set the Data controls DatabaseName property to the name of your excel sheet.

Choose the Data controls Record Source from the RecordSource property drop down list.

Set the Data controls RecordSetType to table.

Set the Data controls Visible property to false (if you like).

Set the DBGrids DataSource to Data1 from the drop down list.

Hit Run.

Thats it!
0
 
JOHNHOAuthor Commented:
problem


1. why in my components didnt see the ole object ? what and how do i get it ?

2. why when i try to set the recordsource with the xls file, it shows me that "coudnt ecrytp data"

why
0
 
TimCotteeCommented:
The OLE object should be in your toolbox. It is usually the last one when you create a standard vb project after the intrinsic data control.
0
 
pmcgivernCommented:
If you use the OLE control then the copy of excel it uses is the actual excel.exe - if this is not on the machine it won't work.  Using the DBGrid gets around this.  

As for the couldn't encrypt data message - I'm not sure.  I can't reproduce that here - there may be a problem with you xls file - it may have complex entries that the data control cannot understand.  If you want you could send me a copy of the xls at pmcgivern@hotmail.com and I can take a look.
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now