Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.setup
Piotr Krasnicki
 
Posts: n/a
Default Problem with exporting xls sheels to txt files separated by tabs

Hello,
I have a problem with exporting Excel sheets to txt files separated by tabs
that I can't find any solutions for. The problem is with fields containing
quotation marks or apostrophes (every other fields are fine). To explain the
situation I'll give you my own example:

Field name in Excel (before export):
R.E.M. - "Stand" - 7" (PROMO)

Field name in text file (after export from Excel):
"R.E.M. - ""Stand"" - 7"" (PROMO)"

As you can see, not only quotation marks were doubled but also they were
added in the beginning and end of the whole phrase (probably to distinguish
the fields). so I have the following question: "How can I properly export
Excel sheet with fields that have quotation marks and apostrophes inside to
avoid adding any unnecessary characters?"

Thank you in advance for any help.

Best regards,
Piotr
  #2   Report Post  
Posted to microsoft.public.excel.setup
Dave Peterson
 
Posts: n/a
Default Problem with exporting xls sheels to txt files separated by tabs

I would think writing a macro to export the data exactly the way you want it
would be the way to go:

Some samples:

Earl Kiosterud's Text Write program:
www.smokeylake.com/excel
(or directly: http://www.smokeylake.com/excel/text_write_program.htm)

Chip Pearson's:
http://www.cpearson.com/excel/imptext.htm

J.E. McGimpsey's:
http://www.mcgimpsey.com/excel/textfiles.html

Earl's program has a supports lots of different options. You may want to see if
that works for you right out of the box.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Piotr Krasnicki wrote:

Hello,
I have a problem with exporting Excel sheets to txt files separated by tabs
that I can't find any solutions for. The problem is with fields containing
quotation marks or apostrophes (every other fields are fine). To explain the
situation I'll give you my own example:

Field name in Excel (before export):
R.E.M. - "Stand" - 7" (PROMO)

Field name in text file (after export from Excel):
"R.E.M. - ""Stand"" - 7"" (PROMO)"

As you can see, not only quotation marks were doubled but also they were
added in the beginning and end of the whole phrase (probably to distinguish
the fields). so I have the following question: "How can I properly export
Excel sheet with fields that have quotation marks and apostrophes inside to
avoid adding any unnecessary characters?"

Thank you in advance for any help.

Best regards,
Piotr


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.setup
Piotr Krasnicki
 
Posts: n/a
Default Problem with exporting xls sheels to txt files separated by ta

Thank you very much for your help. That was exactly what I wanted to achieve.
For those who might have the same problem I had I am enclosing whole macro
that fixs the issue (I found it somewhere on one of tutorial pages). To use
it you just select those fields you want to export and then run that macro.
File is saved under c:\MyOutput.txt

Sub Export()
Dim r As Range, c As Range
Dim sTemp As String
Open "c:\MyOutput.txt" For Output As #1
For Each r In Selection.Rows
sTemp = ""
For Each c In r.Cells
sTemp = sTemp & c.Text & Chr(9)
Next c
'Get rid of trailing tabs
While Right(sTemp, 1) = Chr(9)
sTemp = Left(sTemp, Len(sTemp) - 1)
Wend
Print #1, sTemp
Next r
Close #1
End Sub


Best regards,
Piotr
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot access read-only documents. tomgillane Excel Discussion (Misc queries) 14 February 7th 05 10:53 PM
Problem opening Excel files from Windows Explorer aj Excel Discussion (Misc queries) 2 January 30th 05 06:37 PM
multiple text files URGENT tasha Excel Discussion (Misc queries) 1 December 19th 04 05:44 PM
importing multiple text files URGENT!!! HELP tasha Excel Worksheet Functions 0 December 19th 04 04:26 PM
importing multiple text files??? tashayu Excel Discussion (Misc queries) 0 December 19th 04 02:43 PM


All times are GMT +1. The time now is 02:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"