ryan.gillies
Registered User.
- Local time
- Tomorrow, 06:43
- Joined
- Apr 8, 2011
- Messages
- 53
Hi everyone
I've been trying to search for some kind of method to do the following task, but so far I've come up with nothing!
I have the following code I've typed up which will scan through a text file to find the first instance of an account number (acc) and write that line into a word document.
Then I want to continue writing lines into the document where Mid(Line, 11, 8) = str1 until Mid(Line, 11, 8) <> str1. This bit is what's tripping me up - can anyone point me in the right direction?
This is what I have so far:
I've been trying to search for some kind of method to do the following task, but so far I've come up with nothing!
I have the following code I've typed up which will scan through a text file to find the first instance of an account number (acc) and write that line into a word document.
Then I want to continue writing lines into the document where Mid(Line, 11, 8) = str1 until Mid(Line, 11, 8) <> str1. This bit is what's tripping me up - can anyone point me in the right direction?
This is what I have so far:
Code:
Sub GetAccount(acc As String)
Dim Line As String
Dim str1 As String
str1 = " "
Set fso = CreateObject("Scripting.FileSystemObject")
Set archive = fso.OpenTextFile("I:\test.txt", 1)
With archive
Do Until .AtEndOfStream
Line = .ReadLine
If Mid(Line, 11, 8) = acc Then
Selection.TypeText Line & vbCrLf
End If
Loop
End With
End Sub