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

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

Dave Peterson

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

Learner

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

Dave Peterson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top