ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Read txt file for input error handler (https://www.excelbanter.com/excel-programming/333257-read-txt-file-input-error-handler.html)

Chirs[_2_]

Read txt file for input error handler
 
Hello,

I have a problem reading a text file. My VBA script calls a perl
script, VBA keep searching for a flag.txt so he don't go further with
the macro while perl is running.

What i want is that perl reports his errors in flag.txt (this is
working), and that VBA read the error as input for his error handler.

I have tried several thing but i can get it running. Have someone an
idea? what options do i have to use etc. etc. ??

Allready Thanks for your reply Chris


Andibevan[_2_]

Read txt file for input error handler
 
Hi Chris,

The following bit of code will open the file that is assigned to loopcnt.
It will then loop through every line in the txt file moving the data to a
seperate row on the worksheet.

You could modify this in order to read your error file maybe depending on
whether your error file contains 1 line or multiple lines.

Ta

Andi

Loopcnt = "c:\doc.txt"

Open Var_JrnlFile(Loopcnt) _

For Input As #Loopcnt

r = 0


Do Until EOF(Loopcnt) 'do until end of file #1 is reached

Line Input #Loopcnt, data


ActiveCell.Offset(r, 0) = data

r = r + 1


Loop


'MsgBox (Var_JrnlFile(Loopcnt))



Close #Loopcnt



"Chirs" wrote in message
oups.com...
Hello,

I have a problem reading a text file. My VBA script calls a perl
script, VBA keep searching for a flag.txt so he don't go further with
the macro while perl is running.

What i want is that perl reports his errors in flag.txt (this is
working), and that VBA read the error as input for his error handler.

I have tried several thing but i can get it running. Have someone an
idea? what options do i have to use etc. etc. ??

Allready Thanks for your reply Chris



Chirs[_2_]

Read txt file for input error handler
 
Andi,

Thanks alot for your help this one works.

Chris



All times are GMT +1. The time now is 04:42 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com