+ Reply to Thread
Results 1 to 7 of 7

How to save .xlsx file format to .csv by using macro

  1. #1
    Registered User
    Join Date
    08-15-2015
    Location
    Usa
    MS-Off Ver
    2013
    Posts
    12

    How to save .xlsx file format to .csv by using macro

    Hi Everybody,

    I want to save my xlsx file into .csv file format. I tried the following code. it works fine but when i open my .csv file, a message prompt me " The file format and extension of new .csv file does not match".File could be corrupted"

    Dim file_name As Variant
    file_name = Application.GetSaveAsFilename(FileFilter:="Microsoft csv file (*.csv), *.csv")
    If file_name <> False Then
    ChDir "C:\Users\akarim\Desktop\Data_loading_temp"
    ActiveWorkbook.SaveAs Filename:=file_name
    MsgBox "File Saved!"
    End If

    Can any one help me
    Thanks
    Asif

  2. #2
    Registered User
    Join Date
    06-03-2015
    Location
    Houston, Tx
    MS-Off Ver
    2010
    Posts
    64

    Re: How to save .xlsx file format to .csv by using macro

    Please Login or Register  to view this content.
    This will save the csv in the same location as the .xlsx with the same name

    Change "sheet_name" to the name of the sheet you want saved as an csv
    Last edited by jonathann3891; 08-18-2015 at 04:48 PM.

  3. #3
    Registered User
    Join Date
    08-15-2015
    Location
    Usa
    MS-Off Ver
    2013
    Posts
    12

    Re: How to save .xlsx file format to .csv by using macro

    Thank you very much Jonathann for your help. but I want to save it in different location, the location i mentioned in my query. Secondly, I want to use input box, where user can input file name, as i used used in my question. Could you help me on it. thanks

  4. #4
    Registered User
    Join Date
    06-03-2015
    Location
    Houston, Tx
    MS-Off Ver
    2010
    Posts
    64

    Re: How to save .xlsx file format to .csv by using macro

    Sure, that's an easy fix.

    Please Login or Register  to view this content.
    Dont forget to change the sheet name

  5. #5
    Registered User
    Join Date
    06-03-2015
    Location
    Houston, Tx
    MS-Off Ver
    2010
    Posts
    64

    Re: How to save .xlsx file format to .csv by using macro

    Just noticed that you wanted it saved in a specific location.

    My bad.

    Let me work that out real quick.

  6. #6
    Registered User
    Join Date
    06-03-2015
    Location
    Houston, Tx
    MS-Off Ver
    2010
    Posts
    64

    Re: How to save .xlsx file format to .csv by using macro

    Here you go!

    I added a cancel feature. You can take that out if you want.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-15-2015
    Location
    Usa
    MS-Off Ver
    2013
    Posts
    12

    Re: How to save .xlsx file format to .csv by using macro

    Thanks it does work

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro to convert Xls file format to Xlsx
    By meus in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-06-2015, 04:42 AM
  2. [SOLVED] How to save to PDF instead of .Xlsx file when Looping
    By ShaliniGomes in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-03-2014, 08:26 PM
  3. How to save file with correct file extension, .xls or .xlsx?
    By Alexb77 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-12-2014, 12:52 PM
  4. Replies: 4
    Last Post: 10-23-2013, 12:54 AM
  5. Save to xlsx format to remove macros without VB Project dialog box
    By jecook in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-26-2013, 10:32 PM
  6. [SOLVED] Macro to save file as XLSX in the same folder from where it originated
    By balandri in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-07-2013, 02:28 PM
  7. Save workbook with multiple sheets as csv file and xlsx file
    By excel_vb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-25-2010, 02:41 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1