Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default opening text file triggers vb error

What is logFileName equal to?

Is #1 still open from a previous operation?

-Merk

11/25/03 10:56AM

I have the following problem. In the code below, opening the file
triggers an error. If I comment out the on Error, the file appears to
open just fine and is read from appropriately. The line in question
is "Open logFileName For Input As #1" . I left in all the code but it
is irrelavant (I think) since the code always dies on the open
statement. What am I doing wrong?

Thank you for your help. Please kindly email me at my email address if
possible.
-Elie

On Error GoTo SNAFU
Open logFileName For Input As #1
For i = 0 To numPerms
Line Input #1, textLine
If (x) Then
values = Split(textLine, Chr(9))

On Error GoTo SNAFU
With STARTCELL
For xx = 0 To mapSize - 1
.Offset(i - 1, map(xx).Text).Value = values(xx + 1)
Next xx
End With

Else
x = True
End If
Next i

Close #1

Exit Sub
SNAFU:
MsgBox "There was one or more problems with the file ", _
vbCritical, "Data Read Error (-201)"


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default opening text file triggers vb error

I have the following problem. In the code below, opening the file
triggers an error. If I comment out the on Error, the file appears to
open just fine and is read from appropriately. The line in question
is "Open logFileName For Input As #1" . I left in all the code but it
is irrelavant (I think) since the code always dies on the open
statement. What am I doing wrong?

Thank you for your help. Please kindly email me at my email address if
possible.
-Elie

On Error GoTo SNAFU
Open logFileName For Input As #1
For i = 0 To numPerms
Line Input #1, textLine
If (x) Then
values = Split(textLine, Chr(9))

On Error GoTo SNAFU
With STARTCELL
For xx = 0 To mapSize - 1
.Offset(i - 1, map(xx).Text).Value = values(xx + 1)
Next xx
End With

Else
x = True
End If
Next i

Close #1

Exit Sub
SNAFU:
MsgBox "There was one or more problems with the file ", _
vbCritical, "Data Read Error (-201)"
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default opening text file triggers vb error

Merk-

Thanks for your reply. logFileName changes but in this case is equal
to "d:\Users\Elie\exp11\KeptPromises0-359.txt" .

I am new to vb in general so I don't know the technical deatils of
file opnening and closing. However, if the macro crashed in the middle
of the below loop (brought up a runtime error and I stopeed the
execution) before I had the goto statement, and the file was not
properly closed in the code, would that leave #1 open? If so what
needs to be done.

"Merkling, wrote in message ...
What is logFileName equal to?

Is #1 still open from a previous operation?

-Merk

11/25/03 10:56AM


On Error GoTo SNAFU
Open logFileName For Input As #1
For i = 0 To numPerms
Line Input #1, textLine
If (x) Then
values = Split(textLine, Chr(9))

On Error GoTo SNAFU
With STARTCELL
For xx = 0 To mapSize - 1
.Offset(i - 1, map(xx).Text).Value = values(xx + 1)
Next xx
End With

Else
x = True
End If
Next i

Close #1

Exit Sub
SNAFU:
MsgBox "There was one or more problems with the file ", _
vbCritical, "Data Read Error (-201)"

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
Resolve Error in opening Excel File zip file from a CD? rw5400 Excel Discussion (Misc queries) 1 March 17th 10 03:41 PM
Macro error opening text file Jim C Excel Discussion (Misc queries) 0 November 6th 09 04:05 PM
Error opening edited XML file - Where is the error log? JonBoy Excel Discussion (Misc queries) 0 March 10th 09 09:40 PM
Error when opening an excel file efronk Excel Discussion (Misc queries) 1 March 14th 08 02:03 AM
"Unable to read file" error message when opening a Excel file that contains a PivotTable report. Tim Marsden Charts and Charting in Excel 2 October 15th 05 02:10 PM


All times are GMT +1. The time now is 06:48 AM.

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"