08. juli 2010 - 13:36
Der er
7 kommentarer og 1 løsning
Hente en Excel tabel ind i Access fra eksternt VB-program
Jeg har brug for at kunne hente data fra et excel-ark (samtlige rækker og kolonner fra arket) ind i en mdb. Access databasen er oprettet i forvejen, og excel dataene skal bare proppes ind i en tom tabel, med den øverste række som kolonneoverskrifter. Det hele skal foregå via et eksternt vb-kald...
Annonceindlæg tema
Forsvar & beredskab
Cybersikkerhed, realtidsdata og robuste it-systemer er blevet fundamentet for moderne forsvar.
Yes And the connection is made as well. I´m retrieving data from there in the same program.. Just need to get some additionel data into it from excel.
OK, if Access is installed then you can automate access from your vb program and get Access to import the file. Something like this Dim acc As Access.Application Set acc = CreateObject("Access.Application") acc.OpenCurrentDatabase "C:\test.mdb" acc.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "TableNameGoesHere", "c:\mytestfile.xls
Thanks that did the trick - almost :) Instead of using the first row as columnnames it names the columns F1, F2, F3 etc - and places the column.names from the spreadsheet in the first row of the db.. anything to do about that? Jeff
acc.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "TableNameGoesHere", "c:\mytestfile.xls, True The last parameter (true) for column headings
Kurser inden for grundlæggende programmering