Results 1 to 4 of 4

Thread: Detecting Open File ???

  1. #1

    Thread Starter
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510

    Question

    I have the following simple code in my program:

    Open "myfile.dat" for input as #1
    Input #1, var1
    Input #1, var2
    Close #1

    It is causing a "File Already Open Error" but my program MUST have this info refreshed every so often, but only when the File is closed, so not to cause the above error.

    How can I detect if the file is open???

    Something similar to this:

    If FileAlreadyOpen = False then

    Open "myfile.dat" for input as #1
    Input #1, var1
    Input #1, var2
    Close #1

    Else

    MsgBox "File is Open"

    End If

    Thanks for any suggestions...

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946
    just close it first

    Close #1
    then
    open # 1

    that way you know you got it.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    The other option is to use the new FileSystemObject library. It can be found by selecting the Microsoft Scripting Runtime in the References... dialog box.

    You should be able to test for Nothing...

  4. #4

    Thread Starter
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510
    Thanks for the help. The Close #1 before the Open #1 fixed it. I ASSUMED <-- (and became an ASS) that a Close #1 with no files open would generate an error. But it did'nt. Thanks guyz!

    ...later



    [Edited by mikef on 06-14-2000 at 01:11 PM]

Posting Permissions

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



Click Here to Expand Forum to Full Width