Hi Bas,
Sorry I misread your question at first.
Not at all my area of expertise, but I tried this:
Sub SchrijfTextFile()
Dim i As Long
Open "C:\AFile.txt" For Output As #1
For i = 1 To [a1]
Write #1, i
Next i
Close #1
End Sub
With 2,000,000 in A1.
I then read the file into Excel and of course it told me that not all the data was loaded.
I then instructed Excel to start with row number 1,000,000 (in the Text import wizard) and it worked fine. Started with 1,000,000
and included the rest of the file.
Something with the way records are terminated?

Signature
Kind regards,
Niek Otten
Microsoft MVP - Excel
| Thank you for your post - but the importer should work on large files even
| with the limitation you point out. Here is how:
[quoted text clipped - 83 lines]
| > | Is there prospect that Microsoft will wise up this Wizard and make it work
| > | correctly??
Bas V - 17 May 2008 01:11 GMT
Greetings again Niek and thank you for the follow-up. Erg goeieg van U.
I inspected my text file with TextPad (opens a lot faster than with Notepad)
- nothing there but numbers, decimals, signs, spaces, and paragraph marks -
as expected. I resaved it as a DOS file - got the same exact size as the old
file and the same behaviour on import. I tried it with fixed field
delimiters and as a single column of 30 character strings - all imports stop
on line 1048577 and will only get one line for imports starting any deeper
into the source text file.
I ran the macro and made a test file with 10000000 lines - that ran real
fast - I can use that regardless. However, the import to Excel still behaves
the same. It does not work right with only 2000000 lines in the source file
either.
Since it apparently works on another system, I am beginning to think that
perhaps something is up with mine. I have XP 32 bit with Excel 2007
installed separately. The rest of the Office software (all except Excel)
that I have is still the 2003 version. I am going home and try it on a XP-32
laptop with a full 2007 Office install. If that works, then maybe I have a
fix. If not, then I will be interested to know if you are by any chance
running a 64 bit OS.
Veel Dank.

Signature
Bas V
> Hi Bas,
>
[quoted text clipped - 106 lines]
> | > | Is there prospect that Microsoft will wise up this Wizard and make it work
> | > | correctly??
Bas V - 22 May 2008 00:19 GMT
Attempts to use the text import wizard on very long text files generated by
Niek Otten's script still did not work on a "clean" copy of Excel 2007 as
part of an Office 2007 installedon a Pentium M laptop (2 GB ram) running Win
XP-32 bit. The same behaviour, where the import facility fails beyond line
1048576 of the source text file is observed.
If anybody out there can get this to work, can you please tell me if it is
on a 64 bit system?

Signature
Bas V
> Greetings again Niek and thank you for the follow-up. Erg goeieg van U.
>
[quoted text clipped - 131 lines]
> > | > | Is there prospect that Microsoft will wise up this Wizard and make it work
> > | > | correctly??