Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
272to276
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
272to276
272to276
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Verzeichnis auslesen

Verzeichnis auslesen
01.07.2003 17:08:38
Ron Wirz
Hallo Zäme
Mit der Funktion -A1- lese ich mein gewünschtes Verzeichnis aus. Es wird mir aber der "ganze Verzeichnisbaum" angezeigt. Ich möchte aber mein Startverzeichnis z.b. bereits auf c:\Document and Settings\Temp setzen um so nicht immer alle Verzeichnise ab Root durchklicken zu müssen. Gibt es da etwas?
Danke und Gruss
Ron
---A1---

Function GetDirectory(Optional Msg As String) As String
Dim bInfo As BROWSEINFO
Dim Path As String
Dim r As Long, x As Long, pos As Integer
bInfo.pidlRoot = 0&
If IsMissing(Msg) Then
bInfo.lpszTitle = "Wählen Sie bitte einen Ordner aus."
Else
bInfo.lpszTitle = Msg
End If
bInfo.ulFlags = &H1
x = SHBrowseForFolder(bInfo)
Path = Space$(512)
r = SHGetPathFromIDList(ByVal x, ByVal Path)
If r Then
pos = InStr(Path, Chr$(0))
GetDirectory = Left(Path, pos - 1)
Else
GetDirectory = ""
End If
End Function

5
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Verzeichnis auslesen
02.07.2003 10:16:41
Ron Wirz
Hallo Hans
Danke für Dein Tip. Leider funktioniert dies nicht. (Fehler des Variablentypes)
Habe aber eine andere Lösung gefunden:
............................................

Sub twain()
'Declare a variable as a FileDialog object.
Dim fd As FileDialog
'Create a FileDialog object as a Folder Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
'Nur 1 Directory wählbar
fd.AllowMultiSelect = False
'StartVerzeichnis - wichtig am Schluss muss \
fd.InitialFileName = "U:\IT\Projekte\_Eigene\KUNDEN\Rel51\"
'Declare a variable to contain the path
'of each selected item. Even though the path is a String,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant
'Use a With...End With block to reference the FileDialog object.
With fd
'Use the Show method to display the File Picker dialog box and return the user's action.
'The user pressed the action button.
If .Show = -1 Then
'Step through each string in the FileDialogSelectedItems collection.
For Each vrtSelectedItem In .SelectedItems
'vrtSelectedItem is a String that contains the path of each selected item.
'You can use any file I/O functions that you want to work with this path.
'This example simply displays the path in a message box.
'MsgBox "The path is: " & vrtSelectedItem
strAdr = vrtSelectedItem
Next vrtSelectedItem
'The user pressed Cancel.
Else
End If
End With
'Set the object variable to Nothing.
Set fd = Nothing
'ausgesuchter Wert in Zelle setzen
Range("TextAblage") = strAdr
End Sub


Anzeige
AW: Verzeichnis auslesen
01.07.2003 19:11:43
Hans B.
Hallo Ron,
bin zwar nicht der spezi in sachen excel aber hast du es mal wie folgt versucht!!!
Function GetDirectory(Optional Msg As String) As String
Dim bInfo As BROWSEINFO
Dim Path As String
Dim r As Long, x As Long, pos As Integer

bInfo.pidlRoot = "D:\eigene Dateien" ' hier statt der 0& Ordner definieren
.....
Viel glück
Hans B.

AW: Verzeichnis auslesen
02.07.2003 10:40:39
Ron Wirz
Hallo Hans
Danke für Dein Tip. Leider funktioniert dies nicht. (Fehler des Variablentypes)
Habe aber eine andere Lösung gefunden:
............................................

Sub twain()
'Declare a variable as a FileDialog object.
Dim fd As FileDialog
'Create a FileDialog object as a Folder Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
'Nur 1 Directory wählbar
fd.AllowMultiSelect = False
'StartVerzeichnis - wichtig am Schluss muss \
fd.InitialFileName = "U:\IT\Projekte\_Eigene\KUNDEN\Rel51\"
'Declare a variable to contain the path
'of each selected item. Even though the path is a String,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant
'Use a With...End With block to reference the FileDialog object.
With fd
'Use the Show method to display the File Picker dialog box and return the user's action.
'The user pressed the action button.
If .Show = -1 Then
'Step through each string in the FileDialogSelectedItems collection.
For Each vrtSelectedItem In .SelectedItems
'vrtSelectedItem is a String that contains the path of each selected item.
'You can use any file I/O functions that you want to work with this path.
'This example simply displays the path in a message box.
'MsgBox "The path is: " & vrtSelectedItem
strAdr = vrtSelectedItem
Next vrtSelectedItem
'The user pressed Cancel.
Else
End If
End With
'Set the object variable to Nothing.
Set fd = Nothing
'ausgesuchter Wert in Zelle setzen
Range("TextAblage") = strAdr
End Sub


Anzeige
AW: Verzeichnis auslesen
01.07.2003 17:33:34
geri
Hallo Ron
denke in diesem Falle wäre es einfacher in EXTRAS / Optionen / Allgemein
den Speicherort bzw. Öffnungsort einzugeben
gruss geri

AW: Verzeichnis auslesen
02.07.2003 08:34:52
Ron Wirz
geri
Danke für Deine Antwort.
Das Problem ist, dass ich nicht mein definitiver Speicherort definieren will sondern auswählen möchte wo eine Verzeichnis liegt.
Heute ist es so, dass mir der Verzeichnisbaum ab Root aller vorhandenen Verzeichnisse angezeigt wird.
Gruss Ron

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige