Re: ADO with Excel using .csv? (VB6-Pro)
- From: "Daniel Crichton" <msnews@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 13 Sep 2005 09:31:52 +0100
Frustrated wrote on Tue, 13 Sep 2005 00:57:19 -0700:
> Paul Clement (VB MVP) on the microsoft.public.vb.database.ado forum found
> the error of my ways (thanks again, Paul, if you happen to see this in
> this forum).
>
> I had misunderstood how to do it as explained at
> http://support.microsoft.com/default.aspx?scid=kb;EN-US;257819
> and had stipulated a connection string as:
>
> strcon = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> "Data Source=" & csvFile & ";" & _
> "Extended Properties=""Excel 2002;IMEX=1;HDR=YES"""
>
> It should instead read:
>
> strcon = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> "Data Source=" & csvFile & ";" & _
> "Extended Properties=""Excel 8.0;IMEX=1;HDR=YES"""
>
> The code then worked with a .xls type file just fine, I could iterate
> through all the rows and columns, but it still won't work with a .csv
> export of the same file, and gives a "Run-time error -2147467259
> (80004005) External table is not in the expected format." response. But
> the same .csv file will load into Excel just fine if I double-click the
> .csv file, no parsing errors are then apparent. I'm going to try to get
> around this by using automation to make Excel itself load the .csv file
> and then to save it as a normal .xls type file so that I can then use the
> above connection string to move the Excel "records" over into Access.
> Unless someone can tell me how to make the above connection string work
> with a .csv file, that is!
>
Is there any reason why you're using the Excel driver instead of the Text
driver? The Text driver is designed to read CSV and formatted text files. If
you're just trying to read the data in a recordset and then do something
with, the Text driver should handle it. There's a short example at http://www.vb-helper.com/howto_ado_load_csv.html
Dan
.
- Follow-Ups:
- Re: ADO with Excel using .csv? (VB6-Pro)
- From: Frustrated Again
- Re: ADO with Excel using .csv? (VB6-Pro)
- References:
- ADO with Excel using .csv? (VB6-Pro)
- From: Frustrated Again
- Re: ADO with Excel using .csv? (VB6-Pro)
- From: Frustrated Again
- ADO with Excel using .csv? (VB6-Pro)
- Prev by Date: Re: ADO with Excel using .csv? (VB6-Pro)
- Next by Date: Re: ADO with Excel using .csv? (VB6-Pro)
- Previous by thread: Re: ADO with Excel using .csv? (VB6-Pro)
- Next by thread: Re: ADO with Excel using .csv? (VB6-Pro)
- Index(es):
Relevant Pages
|
|