Convert tabs to spaces

D

Dion Starfire

Is there a way to convert a tab into however many spaces are needed to reach
the next tab stop?

I'm trying to convert an html table to a plain text file. Some of the cells
contain multiple lines. Currently, I copy into word, convert the table to
tab-delimited text, then save as plain text. However, this destroys the
column alignment, and messes up the multi-line 'cells'.

If there's not a built in function for this, how could I write a macro to do
this? (I'm at the 'dabbler' proficiency level, but am very good at using the
built-in help system).
 
G

Graham Mayor

What you are experiencing is inevitable and nothing to do with the plain
text nor the tabs. It concerns the fact that if you have multi-line cell
content, then that content will no longer be multi-line if you convert the
table to text (or save the document containing the table) as plain text. The
cell content opens out and displaces the remaining text, which would remain
tabbed. Frankly I don't see how a macro would be able to sort out such a
random mess.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
D

Dion Starfire

I could almost do this with a simple find and replace, if I could figure out
how to replace the tab with the required number of spaces (varies from line
to line, depending on length of content before tab).

After converting the table to text, the line from the multi-line cells end
with a manual line break, while each (formerly) cell rowends with a paragraph
mark.

So:
replace [character followed by tab] with X spaces, where x equals the
difference between the location of the tab character and the next tab stop.

replace [line break followed by tab] with a number of spaces equal to the
location of the tab (expressed in character columns)
 
G

Graham Mayor

Dion said:
I could almost do this with a simple find and replace, if I could
figure out how to replace the tab with the required number of spaces
(varies from line to line, depending on length of content before tab).

And that's exactly the problem for any solution!

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top