ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Automation - loading text files (https://www.excelbanter.com/excel-programming/313849-excel-automation-loading-text-files.html)

varsha kashyap

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




All times are GMT +1. The time now is 12:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com