View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Pai Pai is offline
external usenet poster
 
Posts: 1
Default Programatically saving an excel .csv file to .xls file...

Hello there,

I have been trying to programatically save and excel test.csv to and test.xls.

I use the following code:

Dim excelapp As New Excel.Application
Set excelapp = New Excel.Application

excelapp.DisplayAlerts = False

Dim c As New Excel.Workbook
Dim f As New Excel.Worksheet

Set c = excelapp.Workbooks.Open(fileName)
Set f = c.Worksheets(1)

saved_Excel_WorkSheet_Name = f.Name

excelapp.SaveWorkspace (saved_Excel_File)

c.Close
Set f = Nothing
Set c = Nothing

excelapp.Quit
Set excelapp = Nothing

I realise that the .xls file is still linked to the .csv file.

As If i delete the .csv file I am unable to open the file.

I tried using the WorkBook.SaveCopyAs method but the format of the data is lost...

whcih is the best way to programatically save a .csv file to .xls.

Thanks in advance,
Srikanth Pai