My query is how to loop through all the files in a specific folder?
I’ve vba code snippet which deletes first and last line of “.b64” file. I want to achieve the same task with all the “.b64” files in a specific folder. Can someone help me tweak this code to loop it?
Here is a code...
Sub delline()
Dim objFSO As Object
Dim objStream As Object
Dim sLines
Dim iNumberOfLines
Dim i
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objStream = objFSO.OpenTextFile("C:\Testing\test1.b64", 1)
sLines = Split(objStream.ReadAll, vbCrLf)
objStream.Close
iNumberOfLines = UBound(sLines)
If iNumberOfLines > 2 Then
Set objStream = objFSO.OpenTextFile("C:\Testing\test1.b64", 2)
For i = 1 To iNumberOfLines - 2
objStream.WriteLine sLines(i)
Next
objStream.Close
End If
Set objStream = Nothing
Set objFSO = Nothing
End Sub
Thanks! Jack