Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: subhankar pandey
  Where is subhankar pandey?
 Kolkata
 India
 subhankar pandey
 To: Cetin Basoz
  Where is Cetin Basoz?
 Izmir
 Turkey
 Cetin Basoz
 Tags
Subject: RE: TextToColumns issue
Thread ID: 210649 Message ID: 210824 # Views: 30 # Ratings: 0
Version: Visual FoxPro 6 Category: Active X Controls & OLE Automation
Date: Thursday, January 08, 2009 6:11:31 AM         
   


> > Hi freinds,
> >
> > I'm working with excel automation where I want to pull excel data to my table . But sometime it is failed becoz field type in excel is differ. My code will only work when sepecific data range in excel file is general format i/o text format. So I decided to go for excel inbuilt TextToCoumns().
> >
> > code is
> >
> > #Define xlDelimited 1
> > #Define xlDoubleQuote 1
> > .Selection.TextToColumns("A1", DataType=xlDelimited, ;
> >   TextQualifier=xlDoubleQuote, ConsecutiveDelimiter=.F., Tab=.T., ;
> >   Semicolon=.F., Comma=.F., Space=.F., Other=.F.,FieldInfo=Array(1,1),;
> >   TrailingMinusNumbers=.T.)
> > 

> > But VFP treat datatype,textqualifier as variable and throw error msg, so I change the below way
> >
> >
> > .Selection.TextToColumns("A1", 1, ;
> > 1, .F., .T., ;
> > .F., .F., .F., .F.,[1,1],.T.)
> > 

> > But again I'm getting OLE error msg !
> >
> > How can I define FieldInfo=Array(1,1) in VFP OLE ?
> >
> > Subhankar
>
>
> #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
> 
> #Define xlTextQualifierDoubleQuote	1
> 
> lcFileName = Sys(5)+Curdir()+'myemployee.txt'
> Use employee
> Copy Fields ;
> 	first_name,last_name,hire_date,emp_id,birth_date ;
> 	to myEmployee.txt Type Delimited
> 
> 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(m.lcFileName,,,xlDelimited,,,,,.t.,,,, @arrFldInfo)
>   .visible = .t.
> endwith

>
> Cetin Basoz

Cetin,

I was asked for how to fix open excel file records (not to open text file throw excel ) should be delimted to general format in .Columns("A:A").

However, thanks for the array declaration concept, I will use near future for how to play with txt file.

regards
subhankar
Subhankar



COMPLETE THREAD
TextToColumns issue Posted by subhankar pandey @ 1/7/2009 7:04:15 AM
RE: TextToColumns issue Posted by Anil Sharma @ 1/7/2009 8:14:58 AM
RE: TextToColumns issue Posted by subhankar pandey @ 1/7/2009 1:01:44 PM
RE: TextToColumns issue Posted by Yousfi Benameur @ 1/7/2009 2:10:33 PM
RE: TextToColumns issue Posted by subhankar pandey @ 1/8/2009 5:32:17 AM
RE: TextToColumns issue Posted by Cetin Basoz @ 1/7/2009 2:15:19 PM
RE: TextToColumns issue Posted by subhankar pandey @ 1/8/2009 6:11:31 AM
RE: TextToColumns issue Posted by Cetin Basoz @ 1/8/2009 4:39:00 PM
RE: TextToColumns issue Posted by subhankar pandey @ 1/9/2009 6:49:09 AM
RE: TextToColumns issue Posted by Cetin Basoz @ 1/9/2009 6:21:23 PM
RE: TextToColumns issue Posted by Borislav Borissov @ 1/9/2009 7:27:13 PM
RE: TextToColumns issue Posted by subhankar pandey @ 1/10/2009 5:48:25 AM