Bekijk de onderstaande video om te zien hoe je onze site als een web app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
Staat daar een deftige tekst en niet #NB, dan is het gelukt, anders moet ik eea. aanpassen.
Sub MijnFotos()
mypath = Sheets("foto").Range("M1").Value 'in deze directory en onderliggende zoeken
mijndir = Filter(Split(CreateObject("WScript.Shell").Exec("cmd /c dir /b /s /ad " & mypath).StdOut.ReadAll, vbCr), mypath, 1) 'alle subdirectories
mijnfiles = Filter(Split(CreateObject("WScript.Shell").Exec("cmd /c dir " & mypath & "/b /s").StdOut.ReadAll, vbCr), "_A.jpg", 1, vbTextCompare) 'alle "_A.jpg"-bestanden in die subdrectories
MsgBox "er zijn :" & vbLf & "- " & UBound(mijndir) + 1 & " subdirectories" & vbLf & "- " & UBound(mijnfiles) + 1 & " _A.jpg-bestanden"
For i = 0 To UBound(mijndir) 'alle subdirectories aflopen
If Len(mijndir(i)) > 1 Then 'niet in de root
flt = Filter(mijnfiles, mijndir(i), 1, vbTextCompare) 'alle bestanden in die subdirectory
b = False 'vlaggetje resetten
If UBound(flt) <> -1 Then 'zitten er bestanden in
For j = 0 To UBound(flt) 'al die bestanden aflopen
sp = Split(flt(j), "\") 'splitten op "\"
b = (sp(UBound(sp) - 1) = Left(sp(UBound(sp)), Len(sp(UBound(sp))) - 6)) 'komt het voorlaatste stuk overeen met het eerste deel van het laatste stuk ?
If b Then Exit For 'indien ja, goed bestand gevonden en klaar
Next
End If
If b Then
s1 = s1 & "|" & mijndir(i) 'voeg subdirectory toe aan de goeie (enkel laatste stuk)
Else
s2 = s2 & "|" & mijndir(i) 'voeg subdirectory toe aan de slechte
End If
End If
Next
sp1 = Split(Mid(Replace(s1, mypath & "\", ""), 2), "|") 'array met alle subdirectories met fotos (mypath is er uit)
sp2 = Split(Mid(Replace(s2, mypath & "\", ""), 2), "|") 'array met de andere(mypath is er uit)
With Sheets("foto").Range("A1")
kleur = IIf(.Interior.ColorIndex = 19, 20, 19)
.Resize(10000).ClearContents
If UBound(sp1) <> -1 Then
With .Resize(UBound(sp1) + 1)
.Value = Application.Transpose(sp1)
.Interior.ColorIndex = kleur
End With
End If
End With
MsgBox "er waren " & UBound(sp2) + 1 & " slechte subdirectories" & vbLf & Join(sp2)
With Sheets("geen foto").Range("A1")
.Resize(10000).ClearContents
.Interior.ColorIndex = kleur
If UBound(sp2) <> -1 Then
With .Resize(UBound(sp2) + 1)
.Value = Application.Transpose(sp2)
.Interior.ColorIndex = kleur
End With
End If
End With
With Sheets("foto").Range("D2") 'voor de volledigheid hier ook even eea wegschrijven
.Resize(10000, 2).ClearContents
.Interior.ColorIndex = kleur
If UBound(mijndir) <> -1 Then
With .Resize(UBound(mijndir) + 1)
.Value = Application.Transpose(Split(Replace(Join(mijndir, "|"), mypath & "\", ""), "|"))
.Interior.ColorIndex = kleur
End With
If UBound(mijnfiles) <> -1 Then
With .Offset(, 1).Resize(UBound(mijnfiles) + 1)
.Value = Application.Transpose(Split(Replace(Join(mijnfiles, "|"), mypath & "\", ""), "|"))
.Interior.ColorIndex = kleur
End With
End If
End If
'.EntireRow.EntireColumn.AutoFit
End With
End Sub
Sub kleuren()
For i = 1 To 255
Cells(i, 1).Interior.ColorIndex = i
Next
End Sub
Global Dict1, Dict2
Sub MijnFotos()
mypath = Sheets("foto").Range("M1").Value 'in deze directory en onderliggende zoeken
mijndir = Filter(Split(CreateObject("WScript.Shell").Exec("cmd /c dir /b /s /ad " & mypath).StdOut.ReadAll, vbCr), mypath, 1) 'alle subdirectories
mijnfiles = Filter(Split(CreateObject("WScript.Shell").Exec("cmd /c dir " & mypath & "/b /s").StdOut.ReadAll, vbCr), "_A.jpg", 1, vbTextCompare) 'alle "_A.jpg"-bestanden in die subdrectories
Set Dict1 = CreateObject("scripting.dictionary") 'aanmaak 2 dictionaries
Set Dict2 = CreateObject("scripting.dictionary")
Const iMax = 1000 'om de 1000, de dictionary dumpen
MsgBox "er zijn :" & vbLf & "- " & UBound(mijndir) + 1 & " subdirectories" & vbLf & "- " & UBound(mijnfiles) + 1 & " _A.jpg-bestanden"
Sheets("foto").Range("A2").Resize(100000).ClearContents
Sheets("geen foto").Range("A2").Resize(100000).ClearContents
For i = 0 To UBound(mijndir) 'alle subdirectories aflopen
If Len(mijndir(i)) > 1 Then 'niet in de root
flt = Filter(mijnfiles, mijndir(i), 1, vbTextCompare) 'alle bestanden in die subdirectory
b = False 'vlaggetje resetten
If UBound(flt) <> -1 Then 'zitten er bestanden in
For j = 0 To UBound(flt) 'al die bestanden aflopen
sp = Split(flt(j), "\") 'splitten op "\"
b = (sp(UBound(sp) - 1) = Left(sp(UBound(sp)), Len(sp(UBound(sp))) - 6)) 'komt het voorlaatste stuk overeen met het eerste deel van het laatste stuk ?
If b Then Exit For 'indien ja, goed bestand gevonden en klaar
Next
End If
If b Then
Dict1.Add Dict1.Count, Replace(mydir(i), mypath & "\", "") 'voeg subdirectory toe aan de goeie (enkel laatste stuk)
If Dict1.Count > iMax Then Dumpen 1
Else
Dict2.Add Dict2.Count, Replace(mydir(i), mypath & "\", "") 'voeg subdirectory toe aan de slechte
If Dict2.Count > iMax Then Dumpen 2
End If
End If
Next
Dumpen 1
Dumpen 2
End Sub
Sub Dumpen(nr)
If nr = 1 Then
If Dict1.Count Then
Sheets("foto").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(Dict1.Count).Value = Application.Transpose(Dict1.items)
Dict1.RemoveAll
End If
Else
If Dict2.Count Then
Sheets("geen foto").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(Dict2.Count).Value = Application.Transpose(Dict2.items)
Dict2.RemoveAll
End If
End If
End Sub
mydir
mijndir
Const iMax = 1000 'om de 1000, de dictionary dumpen
Global Dict1, Dict2, Dict3
Sub MijnFotos()
mypath = Sheets("foto").Range("M1").Value 'in deze directory en onderliggende zoeken
mijndir = Filter(Split(CreateObject("WScript.Shell").Exec("cmd /c dir /b /s /ad " & mypath).StdOut.ReadAll, vbCr), mypath, 1) 'alle subdirectories
mijnfiles = Filter(Split(CreateObject("WScript.Shell").Exec("cmd /c dir " & mypath & "/b /s").StdOut.ReadAll, vbCr), "_A.jpg", 1, vbTextCompare) 'alle "_A.jpg"-bestanden in die subdrectories
Set Dict1 = CreateObject("scripting.dictionary") 'aanmaak 2 dictionaries
Set Dict2 = CreateObject("scripting.dictionary")
Set Dict3 = CreateObject("scripting.dictionary")
Const iMax = 1000 'om de 1000, de dictionary dumpen
MsgBox "er zijn :" & vbLf & "- " & UBound(mijndir) + 1 & " subdirectories" & vbLf & "- " & UBound(mijnfiles) + 1 & " _A.jpg-bestanden"
Sheets("foto").UsedRange.Offset(1).Resize(, 5).ClearContents
Sheets("geen foto").Range("A2").Resize(100000).ClearContents
For i = 0 To UBound(mijndir) 'alle subdirectories aflopen
If Len(mijndir(i)) > 1 Then 'niet in de root
Dict3.Add Dict3.Count, Replace(mijndir(i), mypath & "\", "") 'voeg subdirectory toe aan de goeie (enkel laatste stuk)
If Dict3.Count > iMax Then Dumpen 3
flt = Filter(mijnfiles, mijndir(i), 1, vbTextCompare) 'alle bestanden in die subdirectory
b = False 'vlaggetje resetten
If UBound(flt) <> -1 Then 'zitten er bestanden in
For j = 0 To UBound(flt) 'al die bestanden aflopen
sp = Split(flt(j), "\") 'splitten op "\"
b = (sp(UBound(sp) - 1) = Left(sp(UBound(sp)), Len(sp(UBound(sp))) - 6)) 'komt het voorlaatste stuk overeen met het eerste deel van het laatste stuk ?
If b Then Exit For 'indien ja, goed bestand gevonden en klaar
Next
End If
If b Then
Dict1.Add Dict1.Count, Replace(mijndir(i), mypath & "\", "") 'voeg subdirectory toe aan de goeie (enkel laatste stuk)
If Dict1.Count > iMax Then Dumpen 1
Else
Dict2.Add Dict2.Count, Replace(mijndir(i), mypath & "\", "") 'voeg subdirectory toe aan de slechte
If Dict2.Count > iMax Then Dumpen 2
End If
End If
Next
Dumpen 1
Dumpen 2
Dumpen 3
With Sheets("foto").Range("D2") 'voor de volledigheid hier ook even eea wegschrijven
If UBound(mijnfiles) <> -1 Then
With .Offset(, 1).Resize(UBound(mijnfiles) + 1)
.Value = Application.Transpose(Split(Replace(Join(mijnfiles, "|"), mypath & "\", ""), "|"))
.Interior.ColorIndex = kleur
End With
End If
End If
'.EntireRow.EntireColumn.AutoFit
End With
End Sub
Sub Dumpen(nr)
Select Case nr
Case 1
If Dict1.Count Then
Sheets("foto").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(Dict1.Count).Value = Application.Transpose(Dict1.items)
Dict1.RemoveAll
End If
Case 2
If Dict2.Count Then
Sheets("geen foto").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(Dict2.Count).Value = Application.Transpose(Dict2.items)
Dict2.RemoveAll
End If
Case 3
If Dict3.Count Then
Sheets("foto").Range("D" & Rows.Count).End(xlUp).Offset(1).Resize(Dict3.Count).Value = Application.Transpose(Dict3.items)
Dict3.RemoveAll
End If
End Select
End Sub
Nu werkt de macro dus helemaal...Ik krijg op beiden tabbladen in geen enkele rij nog #NB, enkel de gevraagde nummers. Top!!!!Straks mag je anders eens stoeien met onderstaande regel
Sheets("geen foto").Range("A2").Resize(100000).ClearContents
Sheets("foto").UsedRange.Offset(1).Resize(, 5)
Set Dict1 = CreateObject("scripting.dictionary") 'aanmaak 2 dictionaries
Set Dict2 = CreateObject("scripting.dictionary")
Set Dict3 = CreateObject("scripting.dictionary")
Const iMax = [COLOR="#FF0000"][SIZE=4]1000[/SIZE][/COLOR] 'om de 1000, de dictionary dumpen
MsgBox "er zijn :" & vbLf & "- " & UBound(mijndir) + 1 & " subdirectories" & vbLf & "- " & UBound(mijnfiles) + 1 & " _A.jpg-bestanden"
Sheets("foto").UsedRange.Offset(1).Resize(, 5)...........
[COLOR="#FF0000"]Sheets("foto").range("A4").value="."[/COLOR]
Geen probleem, ik ben al goed geholpen.Sorry voor dat end if-je, als je niet kan testen ..
[COLOR="#FF0000"]With Sheets("foto").Range("D2") [/COLOR] 'voor de volledigheid hier ook even eea wegschrijven
If UBound(mijnfiles) <> -1 Then
[COLOR="#FF0000"]With .Offset(, 1).Resize(UBound(mijnfiles) + 1)[/COLOR]
.Value = Application.Transpose(Split(Replace(Join(mijnfiles, "|"), mypath & "\", ""), "|"))
.Interior.ColorIndex = kleur
End With
End If
Sub Dumpen(nr)
Select Case nr
Case 1
If dict1.Count Then
With Sheets("foto")
If IsEmpty(.Range("A2")) Then .Range("A2").Value = "'" 'staat er niets in A2, zet er dan iets in, zodat er pas gedumpd wordt vanaf A3
.Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(dict1.Count).Value = Application.Transpose(dict1.items)
dict1.RemoveAll
End With
End If
Case 2
If dict2.Count Then
With Sheets("geen foto")
If IsEmpty(.Range("A2")) Then .Range("A2").Value = "'"
.Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(dict2.Count).Value = Application.Transpose(dict2.items)
dict2.RemoveAll
End With
End If
Case 3
If dict3.Count Then
With Sheets("foto")
If IsEmpty(.Range("D2")) Then .Range("D2").Value = "'"
.Range("D" & Rows.Count).End(xlUp).Offset(1).Resize(dict3.Count).Value = Application.Transpose(dict3.items)
dict3.RemoveAll
End With
End If
End Select
End Sub
Case 3
If dict3.Count Then
With Sheets("foto")
If IsEmpty(.Range("D2")) Then .Range("D2").Value = "'"
.Range("D" & Rows.Count).End(xlUp).Offset(1).Resize(dict3.Count).Value = Application.Transpose(dict3.items)
dict3.RemoveAll
End With
End If
End Select
End Sub
We gebruiken essentiële cookies om deze site te laten werken, en optionele cookies om de ervaring te verbeteren.