Tabelle aus geschlossener Datei kopieren
04.11.2003 15:46:01
Tobias
Habe folgender Code gefunden:
Private Sub CommandButton2_Click()
Dim p As String
Dim f As String
Dim s As String
Dim r As String
p = "C:\Documents and Settings\Administrator\My Documents\Ba-03\Leadexport\"
f = "201003 Leadexport-test.xls"
s = "Sheet1"
r = "A1"
MsgBox GetValue(p, f, s, r)
End Sub
Private Function GetValue(path, file, sheet, ref)
' Retrieves a value from a closed workbook
Dim arg As String
' Make sure the file exists
If Right(path, 1) <> "\" Then path = path & "\"
If Dir(path & file) = "" Then
GetValue = "File Not Found"
Exit Function
End If
' Create the argument
arg = "'" & path & "[" & file & "]" & sheet & "'!" & _
Range(ref).Range("A1").Address(, , xlR1C1)
' Execute an XLM macro
GetValue = ExecuteExcel4Macro(arg)
End Function
damit kann man einzelne Zellen ausgeben lassen. Kann mir jemand helfen und den Quelltext ein bisschen erklären und vielleicht so ändern, dass ich ein Tabelle aus der geschlossenen Datei kopieren kann.
thx 4 ur answers!