Results 1 to 3 of 3
Thread: Finding EOF after Open (Excel)
2005-01-21, 06:26 #1
- Join Date
- Mar 2002
- Thanked 30 Times in 30 Posts
Re: Fiding EOF after Open (Excel)
Opening a file For Output means that you're going to write to it, not read from it. So it makes no sense to loop through the file. If you want to read from it, open the file For Input. If you want to write to the end of the file, open it For Append.
2005-01-21, 06:33 #2
- Join Date
- Jun 2001
- New York, New York, Lebanon
- Thanked 1 Time in 1 Post
Finding EOF after Open (Excel)
<img src=/S/hello.gif border=0 alt=hello width=25 height=29> Lougers
I would like to know how to find the EOF when I open a file for output.
I am using this line to open the file for I/O:
<font color=red>Open sPath & "INDEX.txt" For Output As #1</font color=red>
Then I do a <font color=red>Do While Not EOF(1)</font color=red> but the loop ends up not executing. I know the file is full of stuff, its like 500 MB, and when I open it via Notepad, I can see lines of numbers that go beyond the first 100 pages...
So, why, or what, am I doing wrong here? <img src=/S/newbrain.gif border=0 alt=newbrain width=21 height=22> that the loop is not executing? In the loop, I simply read the line of numbers into a cell on the active worksheet.
<img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
Wassim<img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>
2005-01-21, 10:37 #3
- Join Date
- Nov 2001
- Melbourne, Victoria, Australia
- Thanked 0 Times in 0 Posts
Re: Finding EOF after Open (Excel)
From the Windows Scripting help file, the OpenAsTextStream or OpenTextFile can be used to read from, write to, or append to the file:
<td>Constant </td><td>Value </td><td>Description </td> <td>ForReading </td><td>1 </td><td>Open a file for reading only. You can't write to this file. </td> <td>ForWriting </td><td>2 </td><td>Open a file for writing. If a file with the same name exists, its previous contents are overwritten. </td> <td>ForAppending </td><td>8 </td><td>Open a file and write to the end of the file. </td></table>
If you want to write to the end of a file, you should open for append. Not sure what you're doing, but often the sequence is to open for reading then close, followed by open for appending then close.