Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Reading Textfile into a variable

Hi,

I am trying to use the Input function to read the
contents of a text file into a variable. The text file
is very large, and I keep getting the same message
everytime I try to run code that I know works on other
text files (they are smaller):

"Input past end of file"

Here is the code:
____________________________________________
FF = FreeFile ' get the next free file in line

Open SourceFile For Input As FF ' Opens the text file
stream
lChars = LOF(FF) ' lChars is a LONG varaible

AllText = Input(lChars, FF) ' Loads the textfile into
the AllText variable (AllText is a string variable and i
tried Variant too with the same result)

Close FF
_______________________________________________

The number of characters in the text file is 2,685,277.
When the code is executed i get "Input past end of file".

If I force the number of characters to a lower number, it
all works fine.

Any thoughts on what is going on, and if there is a
workaround?

Thanks,

Seth
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Reading Textfile into a variable

Try: Open SourceFile For Binary As FF

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Seth" wrote in message
...
Hi,

I am trying to use the Input function to read the
contents of a text file into a variable. The text file
is very large, and I keep getting the same message
everytime I try to run code that I know works on other
text files (they are smaller):

"Input past end of file"

Here is the code:
____________________________________________
FF = FreeFile ' get the next free file in line

Open SourceFile For Input As FF ' Opens the text file
stream
lChars = LOF(FF) ' lChars is a LONG varaible

AllText = Input(lChars, FF) ' Loads the textfile into
the AllText variable (AllText is a string variable and i
tried Variant too with the same result)

Close FF
_______________________________________________

The number of characters in the text file is 2,685,277.
When the code is executed i get "Input past end of file".

If I force the number of characters to a lower number, it
all works fine.

Any thoughts on what is going on, and if there is a
workaround?

Thanks,

Seth



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
Reading data from another sheet where data is in variable cells JDB Excel Discussion (Misc queries) 4 January 2nd 07 11:04 AM
sumproduct - reading a variable value redneck joe Excel Discussion (Misc queries) 3 May 24th 06 08:02 PM
Reading Data from another workbook... depending on variable in a cell? Rob Moyle Excel Discussion (Misc queries) 4 March 13th 06 04:21 PM
reading/inserting variable dates within a macro Dan Wasser Excel Programming 7 January 8th 04 01:21 PM
Reading specific digits from a numeric variable Srdjan Kovacevic[_2_] Excel Programming 2 October 29th 03 01:54 PM


All times are GMT +1. The time now is 01:25 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"