Setze Excel schon sehr lange ein - aber mit vba habe ich praktisch null Erfahrung (ausser mit Makrorecorder.....)
Nun zu meiner Frage;
Ich habe in einer fiktiven Excel-Tabelle den Range A5:K7, wobei Zeile 5 die Ueberschriften darstellt.
Nun möchte ich diese Daten in die bereits bestehende und gleich aufgebaute Access-DB db1.mdb exportieren.
Den Code habe ich erstellt, er funktioniert aber nicht richtig. Und in Forum habe nichts konkretes für mein Problem gefunden. Das Problem ist, dass der Code Access öffnet, sauber durchläuft, die DB schliesst, aber keine Daten exportiert.......
Der Code sieht wie folgt aus:
Sub Excel_nach_Access()
Dim AccApplication As Access.Application 'Definiert Variable
On Error Resume Next
Set AccApplication = CreateObject("Access.Application")
AccApplication.OpenCurrentDatabase "I:\DB1.mdb"
AccApplication.UserControl = True
Dim adoConnection As ADODB.Connection
Dim adoRecordset As ADODB.Recordset
Dim lngRow As Long
Set adoRecordset = New ADODB.Recordset
adoRecordset.Open "Tabelle1", ado.Connection, _
adOpenKeyset, adLockOptimistic, adCmdTable
IntRow = 6
Do While RANGE("B" & IntRow) ""
With adoRecordset
.AddNew
.Fields("B").Value = RANGE("B" & IntRow).Value
.Fields("C").Value = RANGE("C" & IntRow).Value
.Update
End With
IntRow = IntRow + 1
Loop
adoRecordset.Close
adoConnetction.Close
AccApplication.CloseCurrentDatabase
Für Eure geschätzte Hilfe bin ich sehr dankbar.
Gruss und Dank
Hans Peter