Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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" wrote in message
oups.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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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" wrote in message
oups.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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default 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.t xt ) 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 ?..

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Error: Method OpenTextFile of IFilesystem3 failed Learner[_3_] Excel Programming 1 February 22nd 05 11:25 PM
VBA Error: Method OpenTextFile of IFilesystem3 failed Learner[_3_] Excel Programming 0 February 22nd 05 09:28 PM
VBA Error: Method OpenTextFile of IFilesystem3 failed Learner[_3_] Excel Programming 0 February 22nd 05 09:23 PM
HELP on this strange errror : Method OpenTextFile of IFilesystem3 Failed Learner[_3_] Excel Programming 3 February 22nd 05 02:36 PM
<Method 'Range' of object '_Global' failed error Ken Loomis Excel Programming 2 October 12th 04 01:29 PM


All times are GMT +1. The time now is 10:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"