I'm trying to open a comma delimited text file using OpenText function and setting all the column to "Text" type to preserve the column formating.
The following code work correctly IF I'm not using that FieldInfo=vFormat :
DB = ObjectCreate("Excel.Application")
DB.Visible = @FALSE
DB.UserControl = @FALSE
DB.AskToUpdateLinks = @False
DB.DisplayAlerts =@FALSE
oAPP = DB.Workbooks
vFormat = ArrDimension(16)
ArrInitialize(vFormat, 2)
oConst = ObjectConstantsGet( DB )
xlDelimited = oConst.xlDelimited
xlDoubleQuote = oConst.xlDoubleQuote
oAPP.OpenText(::Filename = vTranslation, Origin=437, StartRow=1, DataType=xlDelimited, TextQualifier=xlDoubleQuote, ConsecutiveDelimiter=@FALSE, Comma=@TRUE,FieldInfo=vFormat)
From Excel example I should have something similar like this:
FieldInfo:=Array(Array(1, 2), Array(2, 2))
I'm already out of idea on how to do that in wbt.
TIA!
Aexes
The VBA statement 'Array(Array(1, 2), Array(2, 2))' is used to create an array of arrays. WinBatch arrays do not support embedded arrays but safearrays do. So
; Make an array of arrays.
Array = ArrDimension(5)
Temp = ArrDimension(2)
Type = 1
for i = 0 to 4 ; For 5 fields
Col = i + 1
Temp[0] = ObjectType("I1", Col)
Temp[1] = ObjectType("I1", Type)
Array[i] = ObjectType("Array", Temp)
next
Notice an error in my previous post. The line 'Type = 1' should be 'Type = 2' to create columns of type 'text'.
Thanks td for the information. Just got the chance to have a try on this and it works perfectly! One minor modification need though. I would need to rename the source file extention from '.csv' to '.txt' in order for it to work correctly.
Again thank you so much for you quide.