Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel (.XLS) to .CSV conversion

Posted on 2010-11-11
5
Medium Priority
?
688 Views
Last Modified: 2012-05-10
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
Comment
Question by:ShaileshShinde
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 6

Assisted Solution

by:nsonbaty
nsonbaty earned 501 total points
ID: 34109611
0
 
LVL 19

Assisted Solution

by:MINDSUPERB
MINDSUPERB earned 249 total points
ID: 34110459


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
 
LVL 1

Author Comment

by:ShaileshShinde
ID: 34116355
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
 
LVL 6

Accepted Solution

by:
nsonbaty earned 501 total points
ID: 34129940
make sure that the OS and the office supporting asian characters, iinstall proofing tools, and chinees lang.. first
0
 
LVL 1

Author Closing Comment

by:ShaileshShinde
ID: 34147865
Thanks A Lot!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question