Live-Forum - Die aktuellen Beiträge
Datum
Titel
24.04.2024 19:29:30
24.04.2024 18:49:56
Anzeige
Archiv - Navigation
880to884
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
880to884
880to884
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Ordnerstruktur

Ordnerstruktur
03.07.2007 09:50:00
Hendryk
hallo zusammen,
ich bin wieder mal am verzweifeln, trotzdem bin ich guter dinge, dass ihr mir helfen könnt. und zwar möchte mein chef die ordnerstruktur des Gruppenlaufwerks vereinfachen, dazu möchte er erstmal eine bestandsaufnahme durchführen.
So und jetzt komm ich ins spiel. meine aufgabe ist es, in excel die Ordnerstruktur abzubilden.
habt ihr vielleicht eine idee wie ich das umsetzen kann. als einziges nützliches werkzeug kommt nur excel in frage, da die dos konsole gesperrt ist und kleine helferchen programme nicht zulässig sind.
vielen dank im voraus
hendryk

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

Betreff
Datum
Anwender
Anzeige
AW: Ordnerstruktur
03.07.2007 10:00:00
Rudi
Hallo,
in ein Modul:

Option Explicit
Dim wksInhalt As Worksheet, vntFiles(), lngFiles As Long
Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, _
ByVal pszPath As String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Sub DateiListe()
Dim FSO As Object, oFolder As Object
Dim strFolder As String
Application.ScreenUpdating = False
Set wksInhalt = ThisWorkbook.Sheets("Inhalt")
Set FSO = CreateObject("Scripting.FileSystemObject")
strFolder = GetDirectory
Set oFolder = FSO.getfolder(strFolder)
lngFiles = 1
With wksInhalt
.Cells.ClearContents
.Cells(1, 1) = "Name"
.Cells(1, 2) = "Ext"
.Cells(1, 3) = "Bemerkung"
.Cells(1, 4) = "Ordner"
.Cells(1, 5) = "kB"
.Cells(1, 6) = "le.Änd."
.Cells(1, 7) = "Erstellt"
.Cells(1, 8) = "Pfad"
.Cells(1, 9) = "Link"
.Range(.Cells(1, 1), .Cells(1, 5)).Font.Bold = True
End With
prcFiles oFolder
prcSubFolders oFolder
With wksInhalt
.Range(.Cells(2, 1), .Cells(lngFiles, UBound(vntFiles, 1))) = WorksheetFunction. _
Transpose(vntFiles)
.Activate
End With
Application.ScreenUpdating = True
End Sub
Sub prcSubFolders(oFolder)
Dim oSubFolder As Object
For Each oSubFolder In oFolder.subfolders
prcFiles oSubFolder
prcSubFolders oSubFolder
Next
End Sub
Sub prcFiles(oFolder)
Dim oFile As Object
For Each oFile In oFolder.Files
ReDim Preserve vntFiles(1 To 9, 1 To lngFiles)
vntFiles(2, lngFiles) = GetExtension(oFile.Name)
vntFiles(1, lngFiles) = Left(oFile.Name, Len(oFile.Name) - Len(vntFiles(2, lngFiles)) -  _
1)
vntFiles(4, lngFiles) = oFolder
vntFiles(5, lngFiles) = Int(oFile.Size / 1024)
vntFiles(6, lngFiles) = oFile.datelastmodified
vntFiles(7, lngFiles) = oFile.datecreated
vntFiles(8, lngFiles) = oFile.Path
vntFiles(9, lngFiles) = "=hyperlink(""" & oFile.Path & """;""" & "Klick" & """)"
lngFiles = lngFiles + 1
Next
End Sub
Private Function GetExtension(strFile As String) As String
If InStrRev(strFile, ".") > 0 Then
GetExtension = Right(strFile, Len(strFile) - InStrRev(strFile, "."))
Else
GetExtension = ""
End If
End Function
Function GetDirectory(Optional Msg) 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


und DateiListe starten.
Gruß
Rudi
Eine Kuh macht Muh, viele Kühe machen Mühe

Anzeige
AW: Ordnerstruktur
03.07.2007 10:21:38
Hendryk
Vielen Dank Rudi,
genau sowas hab ich gesucht
Gruß
Hendryk

AW: Ordnerstruktur
03.07.2007 11:56:00
Andre´
Hallo Rudi,
ich habe Deinen Code getestet, funktiniert soweit ganz gut.
Wenn ich aber auf Abbrechen klicke dann kommt Laufzeitfehler 5 Ungültiger Prozeduraufruf oder ungültiges Argument.
Kannst Du mir bitte sagen, wie ich dies abfangen kann.
MFG Andre

AW: Ordnerstruktur
03.07.2007 12:08:00
Rudi
Hallo,

Sub DateiListe()
Dim FSO As Object, oFolder As Object
Dim strFolder As String
Application.ScreenUpdating = False
Set wksInhalt = ThisWorkbook.Sheets("Inhalt")
Set FSO = CreateObject("Scripting.FileSystemObject")
strFolder = GetDirectory
If strFolder = "" Then Exit Sub
Set oFolder = FSO.getfolder(strFolder)
lngFiles = 1
With wksInhalt
.Cells.ClearContents
.Cells(1, 1) = "Name"
.Cells(1, 2) = "Ext"
.Cells(1, 3) = "Bemerkung"
.Cells(1, 4) = "Ordner"
.Cells(1, 5) = "kB"
.Cells(1, 6) = "le.Änd."
.Cells(1, 7) = "Erstellt"
.Cells(1, 8) = "Pfad"
.Cells(1, 9) = "Link"
.Range(.Cells(1, 1), .Cells(1, 5)).Font.Bold = True
End With
prcFiles oFolder
prcSubFolders oFolder
With wksInhalt
.Range(.Cells(2, 1), .Cells(lngFiles, UBound(vntFiles, 1))) = WorksheetFunction. _
Transpose(vntFiles)
.Activate
End With
Application.ScreenUpdating = True
End Sub


Gruß
Rudi
Eine Kuh macht Muh, viele Kühe machen Mühe

Anzeige
AW: Ordnerstruktur
03.07.2007 12:15:59
Andre´
Hallo Rudi,
Danke funzt prima :-)
MFG Andre

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige