Macro Export table to CSV

STIRRELL

Board Regular
Joined
Dec 30, 2010
Messages
62
Office Version
  1. 365
Hi all,
I am working on a query and need to export the table as CSV and I was surprised to see that was not an option in access. I have been trying many different options to get it to work. ( export as text etc). Short of exporting to excel then converting an extra step I do not want to have to do. Does anyone have a macro that will work? Also is there another version to eliminate the . Some reports I need the headers and others I do not. thanks for your help in advance.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Not sure if you're expressly looking for a code solution or are doing so only because you couldn't find the right way when using the Export options from the ribbon. There definitely is the option to export delimited text without headers in Access 2016 if using the wizard. You choose Text File from the Export menu but don't choose the formatting and layout option box. No headers is the default. You could save the export specification but you'd need one per report.

Or are you looking for a code solution only, and if so, one that builds the specification dynamically or one that runs a stored spec?
 
Upvote 0
Hi- I tried the option above and its still saving as a txt file and unfortuatley for iipay the file needs to be a csv file extension. Also when I try text the formatting looks funny. I need the data to look like a normal excel spreadsheet with data in clean columns and not scattered like the text file More like an excel doc but with the csv extension. Any thoughts? I am looking for an automated solution. Do you know of an add in? I have not had any luck finding one so far.
 
Upvote 0
You can select text as the import and change the file extension to csv. However, the resulting Excel file will put the data as fixed width when you don't want delimited data. That is still in a 'column' but not columns if that is what you meant.
Since you want an automated solution, I don't think this approach will work for you. Did you research ms access vba export query to csv file ? There are tons of code examples to choose from. Could change 'query' to report, table or whatever it is you're wanting to export. Why not do that and find one that is closest to what you need. No real idea what that is here:
- using file dialog (or not) to pick a file
- include headers for this object but not for this one
- looping over a set of objects (e.g. reports) or
- running several sql statements or recordsets
etc.
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,183
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top