Hallo Jakobi,
das geht nur bedingt. Auch wenn eine Datei scheinbar geschlossen ist, wird sie Intern denoch geöffnet.
Beschreib doch was du genau erreichen willst und welche Daten/Dateien du auslesen willst.
Gruß Sepp
AW: Datei auslesen ohne zu öffnen
26.09.2007 21:55:00
Jakobi
Hallo Sepp,
ich möchte in eine Tabellenzelle oder Textdatei einen Pfad als Text hinterlegen, den ich dann in meinem Macro verarbeiten möchte.
Gruß Jakobi
Anzeige
OK, und wo ist das Problem? o.T.
26.09.2007 21:57:34
Josef
Gruß Sepp
AW: OK, und wo ist das Problem? o.T.
26.09.2007 22:05:47
Jakobi
Hallo Sepp,
mein Problem ist, das ich nicht weiß wie es geht.
Jakobi
'Aus Textdatei Sub Pfad_aus_TXT() Dim strPath As String, strFile AsString
strFile = "F:\Temp\pfad.txt"'Pfad und Dateiname der Textdatei - anpassen!
Open strFile ForInputAs #1
Input #1, strPath
Close #1
MsgBox strPath
EndSub
'Aus Excelmappe Sub Pfad_aus_XLS() Dim strPath As String, strFile As String, strSheet As String, strRange As String, result AsVariant strPath = "F:\Temp"'Pfad zur Datei strFile = "test.xls"'Dateiname strSheet = "Tabelle1"'Tabellenname strRange = "A1"'Zelladresse
result = GetValue(strPath, strFile, strSheet, strRange)
If result = "File Not Found"ThenExitSub
MsgBox result
EndSub
PrivateFunction GetValue(path As String, file As String, sheet As String, ref AsString) Dim arg AsString
If Right(path, 1) <> "\"Then path = path & "\"
If Dir(path & file) = "" Then GetValue = "File Not Found" ExitFunction EndIf