ник: nika
Ещё одна проблема при компиляции выдаёт ошибку
1004 Application-definet or object-definet error
в чём проблема не понемаю
спасибо nika.
Public Sub GetFromExcel()
On Error GoTo er
Dim cmd As ADODB.Command 'command objekt für Ausführung den Abfragen mit Parametern
Dim obj As Object
Dim st As Variant
Dim sst As Variant
Dim curGrp As String
Dim i As Long
Dim rst As ADODB.Recordset
Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "DROP TABLE VIA"
cmd.CommandType = adCmdText
cmd.Execute
'Tabelle neu erzeugen
cmd.CommandText = "CREATE TABLE VIA(PE_ID long ,VIAs nvarchar(100),Inhalt nvarchar(100))"
cmd.Execute
Set cmd = Nothing
Set rst = New ADODB.Recordset
rst.Open "SELECT * FROM VIA", CurrentProject.Connection, adOpenForwardOnly, adLockOptimistic
curGrp = "Vehicle System Engineer"
Set obj = GetObject("H:\WS_04470_MERIVA_06-10-10_17-00.xls") 'Pfad zu excel Tabelle
i = 2
j = 8
st = obj.ActiveSheet.Cells(1, 8)
sst = CLng(obj.ActiveSheet.Range("e" & i & ":e" & i))
'If st Like "Vehicle System Engineer(Opel)" Then Exit Sub
'End If
Do While st <> curGrp
Do While sst <> 0
rst.AddNew
rst![PE_ID] = CLng(obj.ActiveSheet.Range("e" & i & ":e" & i))
rst![VIAs] = obj.ActiveSheet.Cells(1, j)
rst![Inhalt] = obj.ActiveSheet.Cells(i, j)
rst.Update
i = i + 1
sst = CLng(obj.ActiveSheet.Range("e" & i & ":e" & i))
Loop
j = j + 1
st = obj.ActiveSheet.Cells(1, j)
Loop
Set obj = Nothing
rst.Close
Set rst = Nothing
Exit Sub
er:
Select Case Err.Number
Case -2147217865
Resume Next
Case Else
MsgBox Err.Number & vbCrLf & Err.Description
End Select
End Sub