That's the code I use but if there's a doublespace between the lines in the string I give it, it doesn't return the value! Can someone modify it to ignore doublespcaes or something!Code:Function RetLineWord(ByVal str As String, linenum As Long, wordnum As Long) As String Dim x&, pos&, pos2& For x = 2 To linenum pos = InStr(pos + 1, str, vbCrLf) pos = pos + 1 Next x For x = 2 To wordnum pos = InStr(pos + 1, str, " ") Next x pos2 = InStr(pos + 1, str, " ") If pos2 = 0 Then pos2 = Len(str) + 1 RetLineWord = Mid(str, pos + 1, pos2 - pos - 1) End Function





Reply With Quote