Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input past end of file

Status
Not open for further replies.

fortage

MIS
Jun 15, 2000
329
US
Can't seem to get around this error. Here is my code
Backup.txt has 3 lines
c:\downloads\*.*
c:\documents\*.*
f:\logs\*.*
****************************************
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("c:\test\backup.txt", 1)
x = 1
Do While f.AtEndOfStream = False
sCmd = "c:\test\PKZIP.exe -P -r c:\test\" & x & ".zip " & f.ReadLine
WshShell.Run sCmd, 1, True
x = x + 1
Loop
******************************************
Any ideas?
 
Tried your code but I don`t have WshShell and pkzip. I used Shell and notepad, it workes fine.

Private Sub Command1_Click()
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("D:\test.txt", 1)
x = 1
Do While f.AtEndOfStream = False
x = x + 1
Shell "notepad.exe " & f.readline, vbMaximizedFocus
Loop
Set fs = Nothing
End Sub


Where exactly do you get an error?
 
I get the same error, and only one instance of notepad opens. Does the txt file need to be setup any particular way?

WshShell.Run "c:\winnt\system32\notepad.exe " & f.readline

Thanks again
 
If you temporary change the
WshShell.Run "c:\winnt\system32\notepad.exe " & f.readline
line whith
debug.print f.readline
Do you get the same error?
 
I'm not familiar with the scripting object, however I have had a similar problem using the native VB file I/O.

A carriage return/linefeed after the 3rd line in the your text file may be causing the problem. The ReadLine method may be trying to read a 4th line which does not really exist.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top