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

  • Thread starter Thread starter Learner
  • Start date Start date
L

Learner

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.....
 
Just a guess...

Maybe that person has scripting disabled?

But VBA has its own way to open a file and read record by record:

Look for Open and maybe "Line Input" in VBA's help.
 
Thanks for the input.

His Macro security is set to Medium and the marcos run on his machine..
Is there any other way to disbale scripts in VBA ?
 
This is actually a windows setting (not VBA or Excel). It's different from
allowing macros to run.

Lots of people (a few years ago) disabled scripting so that they would be less
vulnerable to viruses.
 
Back
Top