popipipo
Meubilair
- Lid geworden
- 21 nov 2006
- Berichten
- 8.647
PHP:
Sub ListFiles()
'Create a list of files
'Run a few checks first...
ActiveSheet.Unprotect
ErrorMsg = "Problem creating list - check path."
'On Error GoTo ErrorHandler
If Range("Path").Value = "" Then GoTo ErrorHandler
Application.ScreenUpdating = False
DirName = Range("Path").Value
If Right(DirName, 1) <> "\" Then DirName = DirName & "\"
NextFile = Dir(DirName)
If NextFile = "" Then MsgBox "Incorrect path specified or no files detected", vbInformation, "List files": Exit Sub
'Clear area for list
Range("Filelist").Offset(1, 0).Select
RowCounter = 0
Range("B" & ActiveCell.Row & ":F65536").ClearContents
Range("B" & ActiveCell.Row & ":F65536").Interior.ColorIndex = 2
'Loop to insert file name and details
Do While NextFile <> ""
ActiveCell.Offset(RowCounter, 0).Value = NextFile
ActiveCell.Offset(RowCounter, 4).Value = NextFile
ActiveCell.Offset(RowCounter, 1).Value = FileLen(DirName & NextFile)
ActiveCell.Offset(RowCounter, 2).Value = FileDateTime(DirName & NextFile)
NextFile = Dir()
RowCounter = RowCounter + 1
Loop
If ActiveCell.Offset(1, 0).Value = "" Then [A1].Select: Exit Sub
'Sort alphabetically
Selection.CurrentRegion.Select
Selection.Sort key1:=Range(ActiveCell.Address), order1:=xlAscending, Header:=xlYes
[A1].Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, AllowFormattingCells:=True, AllowInsertingRows:=True, AllowDeletingRows:=True, AllowSorting:=True
Exit Sub
ErrorHandler:
MsgBox ErrorMsg, vbInformation, "List files"
[A1].Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, AllowFormattingCells:=True, AllowInsertingRows:=True, AllowDeletingRows:=True, AllowSorting:=True
Exit Sub
' sortering toegevoegd
Met deze code importeer ik gegevens van meerdere foto's in excel.
De datum van de foto is echter de datum dat ik de foto op mijn PC heb gezet en niet de datum waarop de foto is gemaakt.
ActiveCell.Offset(RowCounter, 2).Value = FileDateTime(DirName & NextFile)
Hoe moet deze regel veranderd worden zodat ik echt de datum (en tijd) krijg waarop de foto is gemaakt.