cancel
Showing results for 
Search instead for 
Did you mean: 

Save Excel worksheet as csv

JeremyRTDean
Level 5
Newbee question so an example would be helpful...

I'm looking for an action that saves a populated Excel worksheet as a .csv file.

I expect I need to extend the existing VBO Excel SaveWorkbookAs action which uses the code:
wb.SaveAs(filename)

to somehow use the VB parameter:
xlCSV

Any tips on how I do that (or more specifically, the syntax)?

------------------------------
Jeremy Dean
------------------------------
1 BEST ANSWER

Helpful Answers

ewilson
Staff
Staff
Hi @Jeremy Dean,

Change the referenced line in the screen shot below to this:

wb.SaveAs(filename, 6) ' 6 is the equivilent of the xlCSV enum entry.​

24137.png
You might want to actually create a copy of the action first though. Assuming you want to change the action Save Workbook As, right click on the tab and choose Duplicate.​ Give the new action a different name, like Save Workbook As CSV.

Cheers,

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

View answer in original post

6 REPLIES 6

ewilson
Staff
Staff
Hi @Jeremy Dean,

Change the referenced line in the screen shot below to this:

wb.SaveAs(filename, 6) ' 6 is the equivilent of the xlCSV enum entry.​

24137.png
You might want to actually create a copy of the action first though. Assuming you want to change the action Save Workbook As, right click on the tab and choose Duplicate.​ Give the new action a different name, like Save Workbook As CSV.

Cheers,

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

Thanks Eric,

That was quick and helpful.  Using the enumeration value worked.

Can I ask why we use the enumerated value 6 and not the parameter 'xlCSV'?

So this works:
wb.SaveAs(filename, 6)

But this does not:
wb.SaveAs(filename, xlCSV)

There is a handy list of the Excel Save As types here:
https://docs.microsoft.com/en-us/office/vba/api/excel.xlfileformat


------------------------------
Jeremy Dean
------------------------------

@Jeremy Dean,

The XlFileFormat ​enum is defined in the Microsoft.Office.Interop.Excel namespace of the DLL by the same name. I don't recall specifically, but I don't think that DLL/namespace are defined on the VBO. If they were, you should be able to use the enum directly.

Cheers,

------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------

@ewilson What if I want to save this file as a CSV UTF-8 file format

@Arman_K we're updated the asset to include an additional input parameter on the Save Workbook As action to let you specify one of the supported formats from Excel. Should be published later today.

Cheers,
Eric 

@Arman_K version 10.3.6 of the Excel VBO has been published with a new optional input parameter on the Save Workbook As and Save Current Workbook As actions. The new parameter, called File Format, takes a numeric input that corresponds to the format you want to use. You can find a list of the Excel supported formats here. For UTF8 CSV you'd be looking at 62.

Cheers,
Eric