Board index » delphi » Converting tab-delimited text files into XLS files

Converting tab-delimited text files into XLS files

Hi,
I am trying to convert tab-delimited text files into xls files using the
Saveas command.  Where can I find what each of those params are?

Here is the code:
var
    Excel       : TExcelApplication;
    lcid          : Cardinal;
    WBk       : _Workbook;
    oFile       : OleVariant;

Code:
    Excel:= TExcelApplication.Create(Nil) ;
    Excel.Connect ;
    lcid := GetUserDefaultLCID;
    Excel.Visible[lcid]           := False;
    Excel.DisplayAlerts[lcid] := False;
    oFile := FileName;
    WbK:= Excel.Workbooks.Open(oFile,
                                EmptyParam,EmptyParam,
                                EmptyParam,EmptyParam,
                                EmptyParam,EmptyParam,
                                EmptyParam,EmptyParam,
                                EmptyParam,EmptyParam,
                                EmptyParam,EmptyParam,
                                lcid);
    Wbk.SaveAs(oFile, EmptyParam, EmptyParam,
    EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
    EmptyParam, EmptyParam, EmptyParam,
    lcid);

When you are actually using Excel application, you can do File, SaveAs and
select file type as Excel spreadsheet and then it converts the text file
into xls file.  Can I do that setting any of the above params?

Thanks,
Lakshmi

 

Re:Converting tab-delimited text files into XLS files


A description of methods and properties for the objects you can get from the
visual basic help. maybe it is not
installed on your pc but you can easily it postinstall. for office 2000 it
is VBAXL9.chm.
(for postinstallation start setup and have a look at the "Office Tools",
there you would find VB-Help)

"Lakshmi" <lvasude...@sutron.com> schrieb im Newsbeitrag
news:3c86435f$1_2@dnews...

Quote
> Hi,
> I am trying to convert tab-delimited text files into xls files using the
> Saveas command.  Where can I find what each of those params are?

> Here is the code:
> var
>     Excel       : TExcelApplication;
>     lcid          : Cardinal;
>     WBk       : _Workbook;
>     oFile       : OleVariant;

> Code:
>     Excel:= TExcelApplication.Create(Nil) ;
>     Excel.Connect ;
>     lcid := GetUserDefaultLCID;
>     Excel.Visible[lcid]           := False;
>     Excel.DisplayAlerts[lcid] := False;
>     oFile := FileName;
>     WbK:= Excel.Workbooks.Open(oFile,
>                                 EmptyParam,EmptyParam,
>                                 EmptyParam,EmptyParam,
>                                 EmptyParam,EmptyParam,
>                                 EmptyParam,EmptyParam,
>                                 EmptyParam,EmptyParam,
>                                 EmptyParam,EmptyParam,
>                                 lcid);
>     Wbk.SaveAs(oFile, EmptyParam, EmptyParam,
>     EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
>     EmptyParam, EmptyParam, EmptyParam,
>     lcid);

> When you are actually using Excel application, you can do File, SaveAs and
> select file type as Excel spreadsheet and then it converts the text file
> into xls file.  Can I do that setting any of the above params?

> Thanks,
> Lakshmi

Re:Converting tab-delimited text files into XLS files


<<Lakshmi:
I am trying to convert tab-delimited text files into xls
files using the Saveas command.

Quote

As Gnther says, the VBA help file is the place to look.
There is a small problem with the SaveAs method, though,
because one of the parameters that shuld be optional isn't
- you have to supply the xlNoChange argument. In early
binding you may also need to provide an LCID value for some
methods - use the LOCALE_USER_DEFAULT value for this.

  Wbk.SaveAs('Test1.csv', xlCSV, EmptyParam, EmptyParam,
             EmptyParam, EmptyParam, xlNoChange,
             EmptyParam, EmptyParam, EmptyParam,
             EmptyParam, lcid);

--
Deborah Pate (TeamB) http://delphi-jedi.org

  TeamB don't see posts sent via Google or ISPs
  Use the real Borland server: newsgroups.borland.com
  http://www.borland.com/newsgroups/genl_faqs.html

Other Threads