Closed Thread
Results 1 to 5 of 5

Error: Method 'OpenTextFile' of object 'IFileSystem' failed

Hybrid View

Guest Error: Method 'OpenTextFile'... 02-23-2005, 02:06 PM
Guest Re: Error: Method... 02-23-2005, 02:06 PM
Guest Re: Error: Method... 02-23-2005, 04:06 PM
Guest Re: Error: Method... 02-23-2005, 04:06 PM
Guest Re: Error: Method... 03-02-2005, 02:06 PM
  1. #1
    Learner
    Guest

    Error: Method 'OpenTextFile' of object 'IFileSystem' failed

    I have a VBA macro on MS Excel that should open and read from a Text
    file. This is the code


    Dim fs, Tempfile
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set TempFile = fs.OpenTextFile(strInputFile, 1, False)
    Do While TempFile.AtEndOfLine <> True
    ' Process
    Loop


    I found that it throws error in the OpenTextFile mothod above..


    It works for all of our users but one. One guy is getting this strange
    error meesage when the code executes. I checked his MS excel and found
    its same as mine, Office 2003 SP1 (The code works fine in my machine).


    Can you GURUS please help me on this.....


  2. #2
    Tom Ogilvy
    Guest

    Re: Error: Method 'OpenTextFile' of object 'IFileSystem' failed

    check if your problematic user can open the file from their computer.

    Maybe they don't have permissions to that file.

    --
    Regards,
    Tom Ogilvy

    "Learner" <tomjcb@gmail.com> wrote in message
    news:1109180614.658466.127490@g14g2000cwa.googlegroups.com...
    > I have a VBA macro on MS Excel that should open and read from a Text
    > file. This is the code
    >
    >
    > Dim fs, Tempfile
    > Set fs = CreateObject("Scripting.FileSystemObject")
    > Set TempFile = fs.OpenTextFile(strInputFile, 1, False)
    > Do While TempFile.AtEndOfLine <> True
    > ' Process
    > Loop
    >
    >
    > I found that it throws error in the OpenTextFile mothod above..
    >
    >
    > It works for all of our users but one. One guy is getting this strange
    > error meesage when the code executes. I checked his MS excel and found
    > its same as mine, Office 2003 SP1 (The code works fine in my machine).
    >
    >
    > Can you GURUS please help me on this.....
    >




  3. #3
    Learner
    Guest

    Re: Error: Method 'OpenTextFile' of object 'IFileSystem' failed

    Tom,

    yes, that user can manually open the file smoothly....

    checked and also found that he has the latest version of scrrun.dll


  4. #4
    Tom Ogilvy
    Guest

    Re: Error: Method 'OpenTextFile' of object 'IFileSystem' failed

    I would just use the built in FileIO to process the file and see if that
    works.

    http://www.applecore99.com/gen/gen029.asp



    An example:

    Sub ReadStraightTextFile()
    Dim sStr as String
    Dim LineofText As String
    Dim rw as Long
    rw = 0
    Open "C:\FILEIO\TEXTFILE.TXT" For Input As #1
    sStr = ""
    Do While Not EOF(1)
    Line Input #1, LineofText
    sStr = sStr & lineofText
    if len(sStr) >= 178 then
    rw = rw + 1
    cells(rw,1).Value = sStr
    sStr = ""
    End if
    Loop
    'Close the file
    if len(sStr) > 0 then
    cells(rw,1).Value = sStr
    End if
    Close #1
    End Sub

    --
    Regards,
    Tom Ogilvy

    "Learner" <tomjcb@gmail.com> wrote in message
    news:1109185990.435457.146870@z14g2000cwz.googlegroups.com...
    > Tom,
    >
    > yes, that user can manually open the file smoothly....
    >
    > checked and also found that he has the latest version of scrrun.dll
    >




  5. #5
    Learner
    Guest

    Re: Error: Method 'OpenTextFile' of object 'IFileSystem' failed

    I tried this and the Builtin I/O gave a different error. This time it
    is 52 : Bad File number or name

    I looked at MSN KB and it says the problem is because of some bad file
    names such as
    starting with a ", /, lessthan 4 characters in filename etc. (My txt
    file is simple and its like
    \\FullyQualifiedSharedServer\SharedFolder\Mydata.txt ) I am mostly
    certain that this is because the txt file is in the share and this user

    may not have default access to it (Meaning, when he manually double
    clicks on the txt file in question, he is getting a prompt to supply
    user id and password). So my question is, what is the workaround on it
    ? IOW, is it possible to supply UserId/Password as part of the OPEN
    statement ?..


Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1