Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Excel using ADO

Status
Not open for further replies.

petermeachem

Programmer
Aug 26, 2000
2,270
GB
i am trying to display the contents of a spreadsheet in a grid in vb.

What I am doing is:

cConnectionString=
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= D:\Letters\Letters.xls;Extended Properties=Excel 5.0;"

Set cnn = New ADODB.Connection
cnn.ConnectionString = cConnectionString
cnn.Open

Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open csql, cnn, adOpenStatic, adLockOptimistic

where csql is
SELECT * From [Sheet1$] IN 'D:\Letters\Letters.xls'

Which gives me 'Unrecognized database format'

Would someone like to tell me where my weakest link is?

Peter Meachem
peter@accuflight.com
 
You are using an MSAccess 2000 driver to connecct to an Excel spreadsheet. Not working...
Build a DSN and refer to it in your connection:
cnn.open "dsn=YourNewDSN"
 
Bridgit,

Are you sure about that. This is straight a MS doc about changing from dao to ado.

Sub ADOOpenISAMDatabase()

Dim cnn As New ADODB.Connection

cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source=C:\Sales.xls;Extended Properties=Excel 8.0;"

cnn.Close

End Sub


Peter Meachem
peter@accuflight.com
 
Bridgit,

Are you sure about that. This is straight from an MS doc about changing from dao to ado.

Sub ADOOpenISAMDatabase()

Dim cnn As New ADODB.Connection

cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _

"Data Source=C:\Sales.xls;Extended Properties=Excel 8.0;"

cnn.Close

End Sub


Peter Meachem
peter@accuflight.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top