Open Excel spreadsheet from VB 5.0 
Author Message
 Open Excel spreadsheet from VB 5.0

Hi,

I have a problem reading the first line of a Excel table
opened out of VB 5.0.

set DB = MyWork.Opendatabase(Path,True,True,"Excel 5.0;")
set RS = MDB.OpenRecordset("SELECT * FROM Table1", dbOpenDynaset)

I can now move through the whole resultset to get all rows in the
spreadsheet. But I am still not able to read to first row, even after
using a rs.movefirst.

Anyone else had these problems too? Any hints?

Zhanxs in advance.

Marcel



Sat, 30 Dec 2000 03:00:00 GMT  
 Open Excel spreadsheet from VB 5.0
When you read a range as a table DAO uses the first row of cells in the
range as the field names, therefore you need to put something like this to
access the first field :

X = rs(0).Name

Hope this helps

Keith Duncan
Datagen Consultants Ltd.

Quote:
>I have a problem reading the first line of a Excel table
>opened out of VB 5.0.

>set DB = MyWork.Opendatabase(Path,True,True,"Excel 5.0;")
>set RS = MDB.OpenRecordset("SELECT * FROM Table1", dbOpenDynaset)

>I can now move through the whole resultset to get all rows in the
>spreadsheet. But I am still not able to read to first row, even after
>using a rs.movefirst.



Sun, 31 Dec 2000 03:00:00 GMT  
 Open Excel spreadsheet from VB 5.0
[This followup was posted to comp.lang.basic.visual.misc and a copy was
sent to the cited author.]



Quote:
> When you read a range as a table DAO uses the first row of cells in the
> range as the field names, therefore you need to put something like this to
> access the first field :

> X = rs(0).Name

I thought about this too, but there is another problem: If the first row
doesn't contain valid DAO field names it assigns his own fieldnames.
For example: If it contains a number (20095), the field name is
afterwards 'F6'.

Anyone knows how it was solved in Access? With OLE?

Zhanxs in advance.

Marcel



Fri, 05 Jan 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Open Excel spreadsheet from VB 5.0

2. Opening an Excel Spreadsheet from VB

3. Excel 5.0 Spreadsheet Looping

4. Opening a Excel 5.0 Workbook with VB Code

5. Opening existing Excel file through VB 5.0

6. Open Excel Spreadsheet, Save, Close

7. Prompts to update links when opening Excel spreadsheet from Access

8. Test for open linked Excel spreadsheet

9. Open Excel Spreadsheet

10. How to open an Excel spreadsheet from web from

11. Open excel spreadsheet from within Access using VBA

12. Using DDE to open an Excel Spreadsheet

 

 
Powered by phpBB® Forum Software