Creating a MSDOS CSV File

ColNickFury

New Member
Joined
Dec 2, 2008
Messages
5
I am trying to create a MSDOS CSV file anytime the user saves a spreadsheet (i.e. creates a duplicate copy of the data but in a csv file). I used the following command:

ActiveWorkbook.SaveCopyAs "c:\test.csv"

This would allow me to save a CSV file without "modifying" the open workbook\worksheet. But when I attempt to open the csv file in Access, I get garbage. I determined that this is probably do to the file being saved as an "Excel csv" file? What I need is the MS-DOS file type.

The reason behind using the first command was to make sure the user doesn't "know" the file is being created.

Thanks for any help you all can provide.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
I've got to admit I've never heard of either a MSDOS CSV file or an Excel CSV file.

Isn't a CSV file a, well CSV file? ie a text file where the data is comma seperated.

Try using SaveAs and adding an argument specify the file format.

Perhaps this.
Rich (BB code):
ActiveWorkbook.SaveAs "c:\test.csv", FileFormat:=xlCSV
 
Upvote 0
Thanks for the reponse back Norie.

Yeah. I thought the same thing on the CSV file format. Using the command that you gave, Excel allows you to save it as xlCSV or xlCSVMSDOS.

I tried using that command but Excel errors out on me by closing down and then opening back up to "recover" the file that had closed unexpectedly. I am attempting to have this command issued for the Workbook in the BeforeSave event. It will also change the file name extension from xls to csv in the top and then sit there. It recognizes that file has "changed" and this requires me to use the drop down menu from the tool bar to actually save the file. I want to advoid this as the user community might not know what to do.
 
Upvote 0
Do you really need the CSV format?

You mention Access, it's easy to import data from an Excel file into Access if that's what you need to do.:)
 
Upvote 0
The issue is that the users are using one field (in the spreadsheet) as a comment field. They are exceeding the 255 limit. While Excel will recognize up to 32000 characters in th field, Access limits the field to the text limit of 255 when the file is either linked or imported (does not recogizne a memo field). Ideally I would like the comment field to be recognize as a memo field.

I thought that it would be easier to create a CSV file then just import that in and it should work. But no. :((
 
Upvote 0
Sorry I know there are limitations for this sort of thing,, but I don't know exactly what they are or how you would deal with them.

You say there's only 1 field being used, how would you work it into a CSV?

Personally if I was doing something like this I would be trying to find a different solution.

And that might actually involve using Access only, not Excel, Access and CSV files.:)
 
Upvote 0
You say there's only 1 field being used, how would you work it into a CSV?


If you put the spreadsheet into a csv file (with the first row as headers), you can create an import specification that will force the one column to be a memo field instead of the text field.


Another way of doing, (I am looking into this as well) is to use a schema.ini setup but I don't have it quite working right (it's new to me).

Personally if I was doing something like this I would be trying to find a different solution.

And that might actually involve using Access only, not Excel, Access and CSV files.:)

The other issue of usiing Excel vs Access, is that the users have several worksheets that they are using and this one worksheet is the summary of about 5 different sheets. This one summary sheet is used to print off a report. The problem (it is rare but does happen) is when the report is printed and the one field is more than 255 it blows up. I am trying to find a solution to make that report not blow up on them. It all has to do with the field size. :(
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,941
Members
449,094
Latest member
teemeren

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