Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 692
  • Last Modified:

Excel (.XLS) to .CSV conversion

Hello Experts,

I would like to have an excel macro which will do the conversion from XLS to UTF8 CSV file with No Byte Order Marker and no headings.

Can you please provide any sample macro or references for this?

Thanks a lot!
Shailesh
0
ShaileshShinde
Asked:
ShaileshShinde
  • 2
  • 2
3 Solutions
 
MINDSUPERBCommented:


Sub ConvertXLStoCSV()

    Dim strXLSFile As String
    Dim strCSVFile As String
   
    'Change Input and Output folders to relevant location
    Const strInputFolder As String = "C:\Temp\XLS\"
    Const strOutputFolder As String = "C:\Temp\CSV\"
   
    strXLSFile = Dir(strInputFolder & "*.xls")
   
    Do While strXLSFile <> ""
        strCSVFile = Left(strXLSFile, InStrRev(strXLSFile, ".")) & "csv"
        Workbooks.Open strInputFolder & strXLSFile
        ActiveWorkbook.SaveAs strOutputFolder & strCSVFile, xlCSV
        ActiveWorkbook.Close False
        strXLSFile = Dir
    Loop

End Sub


Replace the "C:\Temp\XLS\" and "C:\Temp\CSV\" with relevant folders.  Make sure you have a backslash at the end.

The macro will open every XLS file in the "Input Folder" and export them as CSV files to the "Export Folder".  It assumes that each workbook will contain only one sheet.  If you need to export multiple sheets to multiple files, it can be adapted to do so.

It doesn't test to see if the CSV file already exists and will probably prompt you to overwrite if it does.  Easier to delete the old CSV files from the Output folder first.

Source: http://forums.whirlpool.net.au/archive/565961

Sincerely,
Ed
0
 
ShaileshShindeAuthor Commented:
Hello Experts,

I ran the given macro on .XLS file which contains Chinese contents and found that this does not support for Asian characters and shows up ???.

Thanks,
Shailesh
0
 
nsonbatyCommented:
make sure that the OS and the office supporting asian characters, iinstall proofing tools, and chinees lang.. first
0
 
ShaileshShindeAuthor Commented:
Thanks A Lot!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now