D
diaExcel
I want to put the data from an Excel file in an Access database using VB6.0
(ADO), how can I do that?
Thank you.
(ADO), how can I do that?
Thank you.
here how you can automate excelhttp://www.mvps.org/access/modules/mdl0006.htm
then you can use DAO to put data into appropriate tables
diaExcel said:Hi,
I want to import the Excel file in Access database using ADO in VB6.0, can I
do that and how?
Thank you.
diaExcel said:Hi,
I want to import the Excel file in Access database using ADO in VB6.0, can I
do that and how?
Thank you.
You can connect to the Excel file through ADO to retrieve the
information, given that the information is in some kind of order.
Here's some results of a short web search
http://www.ozgrid.com/forum/showthread.php?t=17158
http://support.microsoft.com/kb/326548/en-us
http://support.microsoft.com/kb/262537/en-us
Let's take it a step further. Say you've got the file xlsfile.xls
somewhere, where the headers are stuffed at the top of the sheet (sheet
named xlsfile, too), I think you should be able to do something like
this:
Dim cn As ADODB.Connection
Dim RecsAffected As Long
Dim SQLString As String
Set cn = New ADODB.Connection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\<path and name of>.xls;" & _
"Extended Properties='Excel 8.0;HDR=Yes'"
cn.Open
SQLString = "INSERT INTO TargetTable In " & _
"'c:\<path and name of>.mdb' " & _
"SELECT * FROM [xlsfile]"
cn.Execute SQLString, RecsAffected, adCmdText + adExecuteNoRecords
Debug.Print RecsAffected
I think you can also be a bit selective with ranges, say
...SELECT * FROM [xlsfile$A1:X120]"
xlsfile here represenging sheet name.
Thank you so much!!!
I have another question....
in VB6.0 in a form I have a DataGrid which is populated with data from
Access, but now I want to add all rows from this datagrid in a different
table in Access, how can I do that, because I've seen that I have to add row
by row and I don't want to in that way, I want that all the rows in a single
step to be added...
Thank you
"RoyVidar" a scris:
[quoted text clipped - 37 lines]xlsfile here represenging sheet name.
Thank you so much!!!
I have another question....
in VB6.0 in a form I have a DataGrid which is populated with data
from Access, but now I want to add all rows from this datagrid in a
different table in Access, how can I do that, because I've seen that
I have to add row by row and I don't want to in that way, I want
that all the rows in a single step to be added...
Thank you