+ Reply to Thread
Results 1 to 12 of 12

Export Access data to CSV file

  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Export Access data to CSV file

    Hi Guys

    I have developed a project using Excel as a frontend and Access as a backend. Now I want to write code that will export data from
    Access table to CSV file .
    Can anybody please help me to do this?

    Regards,

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Export Access data to CSV file

    You can load Access data directly into an Excel workbook.



  3. #3
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Export Access data to CSV file

    Thaks snb, I have done that so now how can I export the data which is stored in sheet1 to csv file using vba.

  4. #4
    Registered User
    Join Date
    04-19-2010
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Export Access data to CSV file

    In the dropdown under the file name when you click save as... You can select csv and wouldn't need to do any vba.

  5. #5
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Export Access data to CSV file

    No actually I want to do it using vba. so that when the users select Date from and Date To and press Generate Report button then it should automatically save the data in sheet1 in CSV file in a different folder .

  6. #6
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Export Access data to CSV file

    I am writng the following code to export excel data to CSV file.
    Please Login or Register  to view this content.
    But when I go to the Export folder and try to open the file then it gives an error message:
    "Excel has detected that Test1.csv is a SYLK file but cann't load it.Either the file has errors or its not a SYLK file.Click OK to try to open the file in a different format.

    I hope anyone can figure it out.

    Thanks

  7. #7
    Registered User
    Join Date
    04-19-2010
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: Export Access data to CSV file

    Ohh well then.

    Please Login or Register  to view this content.
    Also, this is dangerously close to John Walkenbach's book "Excel 2007 Power Programming with VBA" PG(845-846) So I will give him the credit.

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Export Access data to CSV file

    You'd better not use a function if nothing is being calculated.
    Use

    Please Login or Register  to view this content.
    The problem is being caused bij the characters 'ID' in cell A1.
    A preceding hyphen will solve that issue.
    Last edited by snb; 12-21-2011 at 08:58 AM.

  9. #9
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Export Access data to CSV file

    Thanks snb for your help.

  10. #10
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Export Access data to CSV file

    Guys the code works fine but now there is one more problem, when it gets exported to CSV format then the data doesn't display
    in systemetic order.For all rows the data appear in each column properly. If one column has no data for 1 row then 2nd columns
    data shouldn't appear in 1st column space.

    Is there any way to do something like we do in excel ws.usedrange.columns.autofit ?

    Thanks

  11. #11
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Export Access data to CSV file

    Did you read your PM ?

  12. #12
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Export Access data to CSV file

    What is PM? Sorry I didn't get you.

    I want all the data in CSV file in systemetic format so that one column data doesn't get mixed up with another column data.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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