Hi BJ,
That works, and a good 'outside the square' solution too.
I tried using a ";" delimited file to see if it would make any difference...
The problem I encountered is CSV import goes badly wrong if any of the
fields contain more then a certain amount of text in a given field and has to
be manually adjusted in Notepad first. After that, it is simply a matter of
running the macrocode
Workbooks.OpenText Filename := "E:\Data\Parcels.txt", _
Origin := 437, StartRow := 1, DataType := xlDelimited, TextQualifier
:= _
xlDoubleQuote, ConsecutiveDelimiter := TRUE, Tab := FALSE, Semicolon
:= TRUE, _
Comma := FALSE, Space := FALSE, Other := FALSE, FieldInfo :=
Array(Array(1,1), _
Array(2,1),Array(3,1),Array(4,1),Array(5,1),Array(6,1),Array(7,1),Array(8,1),
_
Array(9,1),Array(10,1)
to convert the 10 fields to valid fields including the Postcode...
Still have to be careful when copying this field to assign the .Text and not
the .Value of the field to prevent losing the leading zeros and if moving to
a new worksheet to define the range being 'moved to' to being the correct
'numberformat type' before assigning e.g.
Cells(lCurrentLine, Col_Postcode).NumberFormat = "@" . Otherwise Excel
stubbornly is determined to lose those leading zeros...I even string added a
space to the front of the Value to try to stop this - with no luck! A
definite failing of Excel to anticipate correctly the programmers wishes.
In the end, going back to basics - I was able to change the download file to
be of type XLS from the source program - so when opened, Excel did not try to
change the content of the fields, therefore making a cleaner simpler open
file without having to resort to the text version (above). It seems that
many of the conversion issues are with the way Excel interprets .CSV files
and once it gets an XLS, these are no longer problems... has taught me an
import lesson about .CVS limitations when using Excel.
Thank you both for your assistance, this problem is now solved. Being a
first time user of the forum I am unsure how I mark it closed? Do I need to
do anything to let users know there is no need to address this issue further?
Thanks,
Lex.
PS: Note there is no spell checker before posting?
> If the zips are always in the same location in the downloaded file
> try downloading once as .TXT making sure the Zips are text then
[quoted text clipped - 58 lines]
> > > > forbid it changing the field contents (ie. opening it as straight text or
> > > > ascii equivalent)?