Results 1 to 3 of 3
  1. #1
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 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.

  2. #2
    Bronze Lounger
    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>

    <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>

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Melbourne, Victoria, Australia
    Thanked 0 Times in 0 Posts

    Re: Finding EOF after Open (Excel)

    Hi Wassim

    From the Windows Scripting help file, the OpenAsTextStream or OpenTextFile can be used to read from, write to, or append to the file:

    <table border=1><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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts