BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Opening a text file with Excel

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation
View previous topic :: View next topic  
Author Message
Paul
Guest





PostPosted: Wed Sep 08, 2004 3:18 pm    Post subject: Opening a text file with Excel Reply with quote



Hi

I'm trying to open a csv file using Excel OleAutomation from within Delphi.
I can open the text file, but within the Worksheet things like the telephone
number all drop the 0 at the front e.g. 01221 111111 becomes 1221 111111.
The way around this is to set the FieldInfo parameter in the OpenText
procedure.

The way to do this is to pass an array of arrays, I can find VB examples
which show FieldInfo:=Array(Array(1,2),Array(2,3)).... etc etc. But I can't
find the equivalent Delphi examples.

In the Delphi call FieldInfo is a OleVariant. I've tried the following code
but it does not work.

var
dataType : OleVariant

begin
dataType := VarArrayCreate([1,173], varVariant); //Creates a 173
array element of variants
dataType[31] := VarArrayOf([31, 3]); //Adds an
array at element 31 to create a Date of Birth Field at Column 31
end;

The dataType variable is then passed in the OpenText procedure instead of
the usual EmptyParam

I get the following error

OLE error 800A03EC

Can anyone point me in the right direction please.

Paul


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.