Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Programatically access Excel 2003 spreadsheet

I remember in the past Microsoft distributing an Active library which
would allow a developer to access the various elements of an Excel
spreadsheet. I have Excel 2003 on my computer and yet I do not see such
an ActiveX library listed when I try to import such a library into
Visual Studio .net. Does such an ActiveX library still exist for Excel
or, better yet, a .net asssembly, which allows one to extract data from
an Excel 2003 spreadsheet ?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default Programatically access Excel 2003 spreadsheet

Hello Edward,

ou can inddedd use Microsoft activeX Data Oject 2.x library ( ADO)

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim X As Integer,
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset

With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=C:\MyWorkbook.xls;" & _
"Extended Properties=Excel 8.0;"
.Open
End With

rs.Open "Select * from [MyWorksheet$] ;", cn, adOpenDynamic, adLockReadOnly
'copy every thing
Range("A1").copyfromrecordset rs
'or get the column names
For x = 0 To rs.Fields.Count - 1
Debug.Print rs(x).Name
Next x

'write the data per line
x=0
do while rs.eof=false
range("A1").offset(x,0) = rs.fields("MyCol_Head").value
rs.MoveNext
x=x+1
loop


rs.close
cn.close
set rs=nothing
set cn=nothing

Regards
Jean-Yves

"Edward Diener" wrote in message
...
I remember in the past Microsoft distributing an Active library which would
allow a developer to access the various elements of an Excel spreadsheet. I
have Excel 2003 on my computer and yet I do not see such an ActiveX library
listed when I try to import such a library into Visual Studio .net. Does
such an ActiveX library still exist for Excel or, better yet, a .net
asssembly, which allows one to extract data from an Excel 2003 spreadsheet
?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Programatically access Excel 2003 spreadsheet

Jean-Yves wrote:
Hello Edward,

ou can inddedd use Microsoft activeX Data Oject 2.x library ( ADO)

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim X As Integer,
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset

With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=C:\MyWorkbook.xls;" & _
"Extended Properties=Excel 8.0;"
.Open
End With

rs.Open "Select * from [MyWorksheet$] ;", cn, adOpenDynamic, adLockReadOnly
'copy every thing
Range("A1").copyfromrecordset rs
'or get the column names
For x = 0 To rs.Fields.Count - 1
Debug.Print rs(x).Name
Next x

'write the data per line
x=0
do while rs.eof=false
range("A1").offset(x,0) = rs.fields("MyCol_Head").value
rs.MoveNext
x=x+1
loop


rs.close
cn.close
set rs=nothing
set cn=nothing


Thanks ! Is there any documentation about accessing Excel as an ADO ( or
ADO .net ) data source anywhere ?
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default Programatically access Excel 2003 spreadsheet

Micosoft support
Help files on ADO (connection string) in VBA
Goole !


Regards

JY

"Edward Diener" wrote in message
...
Jean-Yves wrote:
Hello Edward,

ou can inddedd use Microsoft activeX Data Oject 2.x library ( ADO)

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim X As Integer,
Set cn = New ADODB.Connection
Set rs = New ADODB.Recordset

With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=C:\MyWorkbook.xls;" & _
"Extended Properties=Excel 8.0;"
.Open
End With

rs.Open "Select * from [MyWorksheet$] ;", cn, adOpenDynamic,
adLockReadOnly
'copy every thing
Range("A1").copyfromrecordset rs
'or get the column names
For x = 0 To rs.Fields.Count - 1
Debug.Print rs(x).Name
Next x

'write the data per line
x=0
do while rs.eof=false
range("A1").offset(x,0) = rs.fields("MyCol_Head").value
rs.MoveNext
x=x+1
loop


rs.close
cn.close
set rs=nothing
set cn=nothing


Thanks ! Is there any documentation about accessing Excel as an ADO ( or
ADO .net ) data source anywhere ?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access 2003: transferspreadsheet writes over existing spreadsheet ragtopcaddy via OfficeKB.com Excel Discussion (Misc queries) 0 April 21st 08 02:01 PM
access a website from excel 2003 spreadsheet Ricardo New Users to Excel 0 October 25th 06 11:31 PM
Programatically access Excel's Solver? Kevin R[_2_] Excel Programming 3 February 3rd 05 07:40 PM
how to access programatically added controls don bowyer Excel Programming 3 August 8th 04 11:28 AM
Programatically saving XML file as Excel spreadsheet ANN Excel Programming 0 April 22nd 04 09:55 PM


All times are GMT +1. The time now is 05:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"