Avatar of TommyTwoPints
TommyTwoPints
Flag 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
Visual Basic.NET

Avatar of undefined
Last Comment
vadim63

8/22/2022 - Mon
vadim63

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)
vadim63

Dim XL as object
XL= CreateObject("Excel.Application")
Dim Wbk as object
Wbk=XL.Workbooks.Add
Wbk.SaveAs(FileName:=OutputPath, FileFormat:=Excel.XlFileFormat.xlCSV)
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
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
vadim63

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
vadim63

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question