Grabbing Text From A Text File 
Author Message
 Grabbing Text From A Text File

Hi,

I need to access a text file to pull the text out of it and place it into a
document. I am fine with the text once I have it, I can figure out how to put
it into a doc, but what I can't figure out is how to get into my text file.

When I want to enter text into it I use....

Open myTextFile For Append As #1
Print #1, myText
Close #1

I have been trying to access the file using something similar to that but
haven't found anything that works. Any help on this would be appreciated.

Sorry for all the posts lately?

Cordially,

-John
http://www.*-*-*.com/
(Remove NOJUNK from address to respond)



Tue, 20 May 2003 03:00:00 GMT  
 Grabbing Text From A Text File
Hi, John,

Does this work for you?

Sub GetText()
Dim myLine As String, fname As String
fname = "d:\docs\test.txt"   ' <= replace with your file name
Open fname For Input As #1
Do While Not EOF(1)
    Line Input #1, myLine
    Selection.InsertAfter myLine
    Selection.InsertParagraphAfter
      ' or place myLine at a bookmark, or whatever
Loop
Close #1
End Sub


Quote:
> Hi,

> I need to access a text file to pull the text out of it and place it into
a
> document. I am fine with the text once I have it, I can figure out how to
put
> it into a doc, but what I can't figure out is how to get into my text
file.

> When I want to enter text into it I use....

> Open myTextFile For Append As #1
> Print #1, myText
> Close #1

> I have been trying to access the file using something similar to that but
> haven't found anything that works. Any help on this would be appreciated.

> Sorry for all the posts lately?

> Cordially,

> -John
> http://tut00.netfirms.com
> (Remove NOJUNK from address to respond)



Tue, 20 May 2003 03:00:00 GMT  
 Grabbing Text From A Text File
Hi John,

Several ways, here's one of 'em:

Filling an array with textlines from myTextFile, for instance
Open myTextFile For Input as #1
    While Not Eof(1)
        Redim Preserve ArrayMyText(x + 1)
        Line Input#1, ArrayMyText(x)
    Wend
Close #1

Success,
Perry



Quote:
> Hi,

> I need to access a text file to pull the text out of it and place it into
a
> document. I am fine with the text once I have it, I can figure out how to
put
> it into a doc, but what I can't figure out is how to get into my text
file.

> When I want to enter text into it I use....

> Open myTextFile For Append As #1
> Print #1, myText
> Close #1

> I have been trying to access the file using something similar to that but
> haven't found anything that works. Any help on this would be appreciated.

> Sorry for all the posts lately?

> Cordially,

> -John
> http://tut00.netfirms.com
> (Remove NOJUNK from address to respond)



Tue, 20 May 2003 03:00:00 GMT  
 Grabbing Text From A Text File
Hi,

Thank you for the email/post. It does work for me, however I have two
questions.

1. How do I find out about those functions, I have been searching hi and lo for
them and haven't come across them?
2. When it grabs the text, it is striping any formatting, hard returns, etc.,
Is there a way around this.  

Once again, thank you for you help on this issue.

Cordially,

-John
http://tut00.netfirms.com
(Remove NOJUNK from address to respond)



Tue, 20 May 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. HELP,HELP needed- grabbing text from text file

2. grabbing text and displaying it in a text box

3. Grabbing text from another apps text box

4. Save all inbox messages to a text file (or text files) with VBA

5. Reading from a text file and writing toa text file from Vis Bas 6.0

6. Write contents of listbox to text file/populate listbox from text file

7. Text file records comparaison against a Master text file

8. Text file records comparaison against a Master text file

9. I need to grab the last 6 Characters in a text box

10. How to grab (simple) text from my website?

11. Grab any text on screen on mouseover??

12. Grabbing Text from a DOS window.

 

 
Powered by phpBB® Forum Software