Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Opening a Text File
Message
From
19/02/2003 05:27:12
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00754219
Message ID:
00754840
Views:
26
>Thta is good, I had this done so far, However now I have to tell excel that all the columns that will import will be text, because if for some reason I send a string lets say like '00001' excel converts it to 1, in order to avoid this I should tell in the import that specific columns will be text. I made a macro in excel and what it does is to send a string something like this
>
>array(array(1,1),array(1,2)) the ,2 means it is text, ,1 it is general.
>
>When I try to send this as a string the object class gives me and error, how do I do this

Create an array and send by reference :
TEXT TO myVar noshow
0001,VFP7,01/01/2002,skipme,30/01/2003
0002,VFP8,01/31/2003,skipme,29/02/2000
ENDTEXT
lcFileName = fullpath('excelopentexttest.txt')
STRTOFILE(myVar, lcFileName)

#DEFINE xlDelimited	1	
#DEFINE xlFixedWidth	2	

#DEFINE xlGeneralFormat	1	
#DEFINE xlTextFormat	2	
#DEFINE xlMDYFormat	3	
#DEFINE xlDMYFormat	4	
#DEFINE xlYMDFormat	5	
#DEFINE xlMYDFormat	6	
#DEFINE xlDYMFormat	7	
#DEFINE xlYDMFormat	8	
#DEFINE xlSkipColumn	9	
#DEFINE xlEMDFormat	10	


dimension arrFldInfo[5,2]
for ix=1 to 5
  arrFldInfo[ix,1]=ix
endfor
arrFldInfo[1,2]=xlTextFormat
arrFldInfo[2,2]=xlTextFormat
arrFldInfo[3,2]=xlMDYFormat
arrFldInfo[4,2]=xlSkipColumn
arrFldInfo[5,2]=xlDMYFormat

oExcel = createobject('Excel.Application')
with oExcel
  .Workbooks.OpenText(lcFileName,,,xlDelimited,,,,,.t.,,,, @arrFldInfo)
  .visible = .t.
endwith
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform