- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, we have a vba code (Code is attached in the Excel sheet).
The idea is this: The rule looks for a subfolder that contains the first 6 numbers of the name.
this is the rule behind the excel sheet.
The excel file doesn't contains the VBA rule because the forum doesn't support that kind of file.
Sub Zoek_directory_via_FSO()
Dim FSO As New FileSystemObject
Dim myFolder As Folder
Dim mySubFolder As Folder
Dim h1%
Dim schijfadres$
Dim zoek_naar_directory$
schijfadres$ = Blad1.Cells(3, 2)
zoek_naar_directory$ = UCase$(Blad1.Cells(4, 2)) 'ucase maakt er hoofdletters van; Uppercase
'staat er a\ een \ op de laatste positie van het schijfadres ?
h1% = Len(schijfadres$)
If h1% >= 2 And Mid$(schijfadres$, h1%, 1) <> "\" Then schijfadres$ = schijfadres$ + "\"
Blad1.Cells(5, 2) = " .. niets gevonden .."
Set myFolder = FSO.GetFolder(schijfadres$)
For Each mySubFolder In myFolder.SubFolders
'(A) alleerst wordt alles in hoofdletters vergeleken
'(B) de functie instr geeft de positie aan waar een zoekfragment in een string begint
'(C) InStr("THOMAS","A") geeft 5 als resultaat. De A is het 5e karakter
'(D) InStr("K19245 SCHUDBED ARLA FOODS","K19245") geeft 1 als resultaat. De K19245 begint op het 1e karakter
'onderstaand is dit als volgt toegepast:
If InStr(UCase(mySubFolder.Name), zoek_naar_directory$) >= 1 Then 'gelijk aan voorbeeldregel (D)
'Debug.Print mySubFolder.Name
Blad1.Cells(5, 2) = mySubFolder.Name
Exit For
End If 'InStr(UCase(mySubFolder.Name), zoek_naar_directory$) >= 1 Then
Next 'Each mySubFolder
End Sub
I need this rule translated to ILogic. I hope someone can help me.
Met vriendelijke groet, Thomas de Vries
Kind Regards, Thomas de Vries
Solved! Go to Solution.