swaggerbox
02-10-2014, 05:57 AM
Found this code somewhere. How do I change this so that it runs on ALL text files in Sample folder and instead of debug.print, change so that it outputs to excel sheet column A, starting in A2? Can anyone help?
Sub ExtractValueBetweenTags()
Dim myFile As String, text As String, textline As String, posLat As Integer, posLong As Integer
myFile = "E:\Sample\Sample.TXT"
Open myFile For Input As #1
Do Until EOF(1)
Line Input #1, textline
text = text & textline
Loop
Close #1
cellValue = text
openingParen = InStr(cellValue, "<TAG>")
closingParen = InStr(cellValue, "</TAG>")
enclosedValue = Mid(cellValue, openingParen + 5, closingParen - openingParen - 5)
Debug.Print enclosedValue
End Sub
Sub ExtractValueBetweenTags()
Dim myFile As String, text As String, textline As String, posLat As Integer, posLong As Integer
myFile = "E:\Sample\Sample.TXT"
Open myFile For Input As #1
Do Until EOF(1)
Line Input #1, textline
text = text & textline
Loop
Close #1
cellValue = text
openingParen = InStr(cellValue, "<TAG>")
closingParen = InStr(cellValue, "</TAG>")
enclosedValue = Mid(cellValue, openingParen + 5, closingParen - openingParen - 5)
Debug.Print enclosedValue
End Sub