OT: Any VBS, VBA, Excel specialist out there who might help?

Ken Ray kray at sonsothunder.com
Thu Jul 23 13:20:57 EDT 2009


> My csv file is structured like this:
> 
> ArtNr;ShortDescription;LongDescription;ManufactureNo;EAN;Manufacturer;Stock
> 010002;Epson LQ300; Epson LQ 300 Matrixdrucker;C11C63800;8715946316949;Epson;2

It looks to me like the problem may be in the Workbooks.OpenText call.
Here's the params according to Microsoft:

Workbooks.OpenText(Filename, Origin, StartRow, DataType, TextQualifier,
ConsecutiveDelimiter, Tab, Semicolon, Comma, Space, Other, OtherChar,
FieldInfo, TextVisualLayout, DecimalSeparator, ThousandsSeparator,
TrailingMinusNumbers, Local)

Here's how your current parameters map to this:

   FileName  --> sInPath
   Origin  --> (empty)
   StartRow  --> (empty)
   DataType  --> (empty)
   TextQualifier --> xlTextQualifierNone
   ConsecutiiveDelimiter  --> (empty)
   Tab  --> (empty)
   Semicolon  --> True
   Comma  --> (empty)
   Space  --> (empty)
   Other  --> (empty)
   OtherChar  --> (empty)
   FieldInfo --> Array(Array(1, 2), Array(2,2), Array(3,2), Array(4,2),
                          Array(5,2),Array(6,1), Array(7,1), Array(8,1),
                          Array(9,1), Array(10,1), Array(11,1), Array(12,2))
   TextVisualLayout  --> (empty)
   DecimalSeparator  --> (empty)
   ThousandsSeparator  --> (empty)
   TrailingMinusNumber  --> (empty)
   Local  --> (empty)

Notice that the "DataType" parameter is empty. If you do it this way, Excel
is left to try and figure out the column format (and it ignores your "True"
in "Semicolon", but apparently up until now was able to figure things out
properly). 

Try passing "xlDelimited" in the "DataType" parameter, which will tell Excel
that the data is definitely delimited, and force it to look at the
"Semicolon" parameter to tell it that it's semicolon-delimited.

Ken Ray
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/





More information about the use-livecode mailing list