View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
varsha kashyap varsha kashyap is offline
external usenet poster
 
Posts: 1
Default Excel Automation - loading text files

Hi,

I am trying to load a csv file in excel. I am using the "OpenText" method so
that I can format particular columns to text format. The code which I am
using is :

pRet = application.GetWorkbooks();
ASSERT( pRet != NULL );
workbooks.AttachDispatch(pRet);

workbooks.OpenText(LPCTSTR(csvfile),COleVariant("1 "),COleVariant("3"),
COleVariant("xlDelimited"),1,

COleVariant("False"),COleVariant("False"),COleVari ant("False"),

COleVariant("True"),COleVariant("False"),COleVaria nt("False"),

COleVariant("NULL"),COleVariant("Array(Array(3,2), Array(4,2))"),COleVariant("NULL"));*/


It should be noted that I am trying to format the 3rd and the 4th column to
text format.
This code gives me an error :

_OpenText method of Workbooks class failed


Maybe one of you can see what I am doing wrong here.

Thanks,
Varsha Kashyap