ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Excel plugin to quickly export selection to text file (csv, tab-delimited, etc.)

(1/3) > >>

superboyac:
In Excel, whenever you want to convert your data to a text file (csv, tab-delimited, whatever) it asks like 3 questions every single time and it gets really annoying.  You have to do a "save as" and pick the format you want to save it as, then it tells you like 2 times saving it will remove the formatting (duh!).  So freakin annoying.  The worst part is that afterwards, the actualy open excel document is now the exported text file (because it was done as a "save as" it assumes you want to change the current document to the new one).

Is there a plugin or something where I can just highlight a group of cells and export it to a text file?

bjk:
I'm not sure if it is a pefect solution to your problem but you may look here:

http://www.asap-utilities.com/asap-utilities-excel-tools-tip.php?tip=197&utilities=Export.

I think that the ASAP tools are indispensable for everyone working with Excel. Besides this, these tools
http://www.excel-extools.com/ are very handy, too.


AndyM:
Try putting this in your personal.xls.  It will save the current .xls file to a .csv file with the same name in the same directory, close the .csv file and re-open the .xls file.

If you do this often, it might be worth assigning the macro to a button, put it on a menu, or assign it to a shortcut key.


--- ---Sub SaveCSV()

'Might have to have Tools>References>MicrosoftScriptingRuntime checked

Dim fnamexls As String
Dim fnamecsv As String

fnamexls = ActiveWorkbook.FullName
fnamecsv = Replace(fnamexls, ".xls", ".csv")

    ActiveWorkbook.SaveAs Filename:=fnamecsv, _
        FileFormat:=xlCSV, CreateBackup:=False

ActiveWorkbook.Close SaveChanges:=False
Workbooks.Open Filename:=fnamexls
 
End Sub

(just realized it might discard any changes you made to the .xls file, so either save that first, or add a line in the code to save the .xls file)

I'm no programmer, so ***use this at your own risk!!!***

superboyac:
I'm not sure if it is a pefect solution to your problem but you may look here:

http://www.asap-utilities.com/asap-utilities-excel-tools-tip.php?tip=197&utilities=Export.

I think that the ASAP tools are indispensable for everyone working with Excel. Besides this, these tools
http://www.excel-extools.com/ are very handy, too.
-bjk (May 06, 2007, 11:48 AM)
--- End quote ---
Awesome!  That is so cool.  What would I do without you guys?

AndyM:
I didn't read your original post carefully enough.  You want to save
only the highlighted selection to a new .csv file, and the macro I
gave you saves the entire sheet to a .csv file.

This will save the highlighted selection to a .csv file with the same
name as the original .xls file, and will reload the original .xls
file:



--- ---Sub SaveSelectionCSV()

Dim fnamexls As String
Dim fnamecsv As String

fnamexls = ActiveWorkbook.FullName
fnamecsv = Replace(fnamexls, ".xls", ".csv")

Selection.Copy
Sheets.Add
ActiveSheet.Paste

    ActiveWorkbook.SaveAs Filename:=fnamecsv, _
        FileFormat:=xlCSV, CreateBackup:=False

ActiveWorkbook.Close SaveChanges:=False
Workbooks.Open Filename:=fnamexls
 
End Sub

In either case, be careful you are not *starting* with a .csv file.  If you answer "yes" to "do you want to overwrite the current file?", that's exactly what will happen.

On the other hand, if you are starting with an .xls file and you already have a .csv file of the same name, you can decide whether or not to overwrite the old .csv file as you see fit.

Navigation

[0] Message Index

[#] Next page

Go to full version