How do I convert tabs back to spaces in a document?

  • Thread starter David Atherton-Cooper
  • Start date
D

David Atherton-Cooper

I have a document that is properly formatted (using tabs).

Unfortunately, I need to paste this formatted text into a plan text field on
a web application, which loses all of the formatting.

I am trying to put a macro together that will read a block of text and
replace any tabs with an appropriate number of spaces.

Any ideas?
 
J

Jay Freedman

On Sat, 26 Nov 2005 05:18:04 -0800, David Atherton-Cooper <David
I have a document that is properly formatted (using tabs).

Unfortunately, I need to paste this formatted text into a plan text field on
a web application, which loses all of the formatting.

I am trying to put a macro together that will read a block of text and
replace any tabs with an appropriate number of spaces.

Any ideas?

The hard part is deciding what is "an appropriate number of spaces."
Once you know that, you don't even need a macro, just open the Replace
dialog, put ^t in the Find box, the spaces in the Replace box, and
click Replace All.

If you really need a macro because of other considerations, please
describe the entire process so we can see how this fits in.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
T

Tony Jollans

So you have nice formatting in Word using a proportional font.

And you think all you need to do to replicate it in a fixed width font in a
web text control is swap tabs for a few spaces?

To determine the number of spaces required for any one tab you'll need to
look at the horizontal end position of the tab (or the start position of the
following text) relative to the page, then find the character on the line
above that's closest to that horizontal position and then see how many
characters into the line that is (after taking account of any other tabs on
that line) and then count how many characers you've got in the line you
first looked at and add in the difference in spaces - always assuming you
don't get any line overflow (or underflow) because of the change of font.

Unless you're doing this *very* frequently it isn't worth the effort of
trying to automate it.
 

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