> I am using TextStream to create documents. I also need to grab
> several text strings from the documents. At the moment, I create and
[quoted text clipped - 9 lines]
>
> Ed

Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Thanks for replying, Jay. Sorry I wasn't more specific - I should know by
now!
Right now, I'm scanning through each created document for certain text
strings as "labels" for information to populate an Excel file as a document
index. For instance, I will search each doc for "3. TITLE: "; when found,
the range can then be collapsed and reset either left or right to encompass
the doc title, which is captured as a string and written to the Excel file.
It works, but only if I close each TextStream doc and reopen as a Word
doc, search, and close. That eats up a lot of time, and I'd like to make it
faster. I do hundreds, often thousands, of docs like this.
Ed
> > I am using TextStream to create documents. I also need to grab
> > several text strings from the documents. At the moment, I create and
[quoted text clipped - 16 lines]
> strNewTIR to find substrings. Can you describe more explicitly what you're
> trying to do?
Helmut Weber - 02 Nov 2004 19:27 GMT
Hi Ed,
as far as I understand this, you don't process word files
at all, but text-files. All you need is to make use of the string
functions availabe in any programming language. You got
delimiters, such as chr(13), which split the text-string up
into discrete parts. If such a part contains "3. TITLE: ",
then you may put that part into a database or an Excel-Sheet,
or process it further beforehand. I think you have to read
character by character, store what's coming in into a string,
until a delimiter is found, process the result, and do with it
whatever you like, depending on the processing.
Certainly easier said than done.
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Ed - 02 Nov 2004 19:33 GMT
Hi, Helmut. The process actually involves taking a very long text file,
finding a certain portion and saving it to a string, then opening a new
file and writing the string to it. From this, I need to extract some
internal
text as strings to populate and Excel file which is used as an index. I'm
trying to get around closing and reopening the file.
Ed
> Hi Ed,
> as far as I understand this, you don't process word files
[quoted text clipped - 14 lines]
> Word XP, Win 98
> http://word.mvps.org/
Helmut Weber - 03 Nov 2004 11:07 GMT
Hi Ed,
in principle it could work like this:
Public Sub Test601()
Dim sInp As String
Dim sTmp As String
Open "c:\test\textfile.txt" For Input As #1
'---
While Not EOF(1)
sInp = Input(1, #1) ' 1 character
If sInp <> Chr(13) Then
sTmp = sTmp & sInp
Else
If InStr(sTmp, ". TITLE: ") Then
MsgBox "got you : " & sTmp ' !!!
End If
sTmp = ""
End If
Wend
'---
Close #1
End Sub
But a lot depends on the structure of the textfile.
It could be, theoretically, that there is no chr(13)
in it. Or no other character other than a-z, 0-9 etc.
Then it would not have a structure at all, or at
least a structure, that would be difficult to accesss.
If the file is structured by lines, then you may
read line by line and not character by character,
as I did here, which is by far the slowest way.
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000