ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Exporting to CSV without text qualifiers (https://www.excelbanter.com/excel-programming/373082-exporting-csv-without-text-qualifiers.html)

Centurius

Exporting to CSV without text qualifiers
 
Hi guys,
I've been fiddling with VBA again, and seem to have come unstuck.
I work at a cabinetmakers, and I'm writing a macro to export a list of
parts to a program that talks to our saw. The program uses a CSV file
to read in all the sizes, descriptions etc etc.

Problem is, that i need one of the fields to equal " " (with the
qualifiers)
I've tried the following, and countless others, but these seem to be
the closest

Workbooks(Paste_Book).Activate 'D = " " (Material String
Field 2)
Range("D1:D" & bot2).Value = """ """

Workbooks(Paste_Book).Activate 'D = " " (Material String
Field 2)
Range("D1:D" & bot2).Value = " "

The first looks right when I open the xls file (before it exports to
csv), but after the exporting, it gives me """ """ in the cell

the second gives me a space only in excel, and after the exporting,
also leaves me with only a space... and no qualifiers

hope that made a little bit of sense, and i hope someone here can help.

thanks in advance!


Centurius

Exporting to CSV without text qualifiers
 
as a further note,
the saw program requires text qualifers ("" 's) surrounding each
non-numerical field. and they only seem to be written into the CSV when
there is non alpha-numerical characters in the cell (ie. the text
qualifer ")
so if i leave the text qualifiers out i get none.. and if i put them in
(before the exporting) then i end up with 3!

i only want one =(


Centurius

Exporting to CSV without text qualifiers
 
and in case this has something to do with it (probably is where the
problem lies..)

the following is the line i eventually use to export to CSV

ActiveWorkbook.SaveAs Filename:=thisname & ".pts", FileFormat:= _
xlCSVMSDOS, CreateBackup:=False


Centurius

Exporting to CSV without text qualifiers
 
at the moment, i'm running my macro, then opening the exported CSV file
in notepad, and doing a find/replace """ with "
this fixes it right up and the saw program can open it no worries...

as much as i enjoy talking to myself, i think i'll leave it to the
experts now.
either a way to stop excel adding its own text qualifiers, or even a
workaround way to make notepad or similar do the replacing
automatically, would be much appreciated

thanks in advance,
Dan

(centurius [at] hotmail dot com)


Tom Ogilvy

Exporting to CSV without text qualifiers
 
Perhaps this code to write your file:

http://www.cpearson.com/excel/imptext.htm import/export text files

--
Regards,
Tom Ogilvy

"Centurius" wrote in message
ups.com...
at the moment, i'm running my macro, then opening the exported CSV file
in notepad, and doing a find/replace """ with "
this fixes it right up and the saw program can open it no worries...

as much as i enjoy talking to myself, i think i'll leave it to the
experts now.
either a way to stop excel adding its own text qualifiers, or even a
workaround way to make notepad or similar do the replacing
automatically, would be much appreciated

thanks in advance,
Dan

(centurius [at] hotmail dot com)





All times are GMT +1. The time now is 06:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com