cow18
Terugkerende gebruiker
- Lid geworden
- 24 mei 2008
- Berichten
- 4.279
- Besturingssysteem
- Windows
- Office versie
- Excel365
een beetje proberen op alles te anticiperen.
Let wel, helemaal bovenin de module moet die eerste regel staan !!!
Let wel, helemaal bovenin de module moet die eerste regel staan !!!
Code:
[COLOR="#FF0000"][SIZE=3]Option Compare text[/SIZE][/COLOR]
Sub TestCow()
mijnpath = Range("$B$9") & Range("$B$10")
a0 = Split(CreateObject("wscript.shell").exec("cmd /c Dir """ & mijnpath & """*.pdf /b").stdout.readall, vbCrLf) 'alle pdf's in die subdirectory
a1 = Filter(a0, "pietje-", True, vbTextCompare) 'alle pdf's die "pietje-" bevatten
For i = 0 To UBound(a1) 'alle dergelijke files aflopen
If a1(i) Like "pietje-####.pdf" Then 'explicit van dat formaat ?
imax = Application.Max(imax, CLng(Mid(a1(i), 8, 4))) 'grootste cijfer onthouden
End If
Next
i = Application.Max(UBound(a0) + 2, imax + 1)
MsgBox "aantal pdf's +1 = " & UBound(a0) + 2 & vbLf & "grootste teller + 1 = " & imax + 1 & vbLf & vbLf & "volgende file wordt : pietje-" & Format(i, "0000") & ".pdf"
End Sub