Link to home
Start Free TrialLog in
Avatar of TommyTwoPints
TommyTwoPintsFlag for Thailand

asked on

Save excel as csv format when using Late Binding

Hi Experts,

I am using late binding to open Excel in vb.net 2002.

I have opened a workbook and wish to save it in CSV format, problem is when i type Format:=xlcsv as an argument for the workbook.saveas function call the error is xlcsv is not declared. I know why this happens; its because excel is not referenced.

Here is a similar example to my code

Dim XL as object
XL= CreateObject("Excel.Application")
Dim Wbk as object
Wbk=XL.Workbooks.Add
Wbk.SaveAs(FileName:=OutputPath, Format:=XlCsv)

Is there a way i can save the workbook as a csv when using late binding?

Cheers,

Tom
Avatar of vadim63
vadim63
Flag of United States of America image

try

'FileFormat:=Excel.XlFileFormat.xlCSV:

Dim XL as object
XL= CreateObject("Excel.Application")
Dim Wbk as object
Wbk=XL.Workbooks.Add
Wbk.SaveAs(FileName:=OutputPath, 'FileFormat:=Excel.XlFileFormat.xlCSV)
Dim XL as object
XL= CreateObject("Excel.Application")
Dim Wbk as object
Wbk=XL.Workbooks.Add
Wbk.SaveAs(FileName:=OutputPath, FileFormat:=Excel.XlFileFormat.xlCSV)
Avatar of TommyTwoPints

ASKER

Hi Vadim,

This does not work as Excel is not referenced in the project as i am using late binding,

thanks anyway,

Tom
OK, I got it.

Try:

Dim XL as object
XL= CreateObject("Excel.Application")
Dim Wbk as object
Wbk=XL.Workbooks.Add
Wbk.SaveAs(FileName:=OutputPath, FileFormat:=6)
ASKER CERTIFIED SOLUTION
Avatar of vadim63
vadim63
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial