Converting Underlines to dashes

W

Word Heretic

G'day "Amir" <[email protected]>,

This is a non-trivial typsetting problem that I could discuss on a
commercial basis with you. My only help is Selection.Information(Gosh!
Look at all these funky things!) may help you.

Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Amir reckoned:
 
A

Amir

Hi!

I'm trying to build a macro that will search for underlined fonts in all the
document,
and replace them with equivalent number of - characters one line below.

for example:

if 'leads' is underlined:

First sentence leads to secend

sentence in paragraph.

will turn to:
First sentence leads to secend
-----
sentence in paragraph.

(The original space between the two sentences was made with line spacing=2,
not with "Enter" key)

I have a function to count how many lines there are in each paragraphs
(CorrectionsMarking_CountLines)

Almost all of the paragraphs in the document have 2 lines line spacing,
and I want that the - signs to go in the 'spaces' between the lines.
Font is always Courier New, size 12 (so that each underlined character
should produce 1 dash because they have the same width)

In order to do so I have to change the line spacing to 1, and add empty
lines to keep the document format.

I'm having difficulties with dealing this problem and I though that maybe
someone has solved it once..

Can anyone help?
 
S

Shauna Kelly

Hi Amir

If you want a rough approach that approximates your requirements, try

Sub ReplaceStraightUnderlineWithDottedUnderlineDoubleSpaced()
With Selection.Find
.Text = ""
.Font.Underline = wdUnderlineSingle
With .Replacement
.Text = ""
.Font.Underline = wdUnderlineDotted
.ParagraphFormat.LineSpacingRule = wdLineSpaceDouble
End With
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
.Replacement.ClearFormatting
.ClearFormatting

End With

End Sub


Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
A

Amir

Hi Shauna,

This is a bit different from what I meant.

I meant replacing the underlines with real characters of dashes: '-', which
will be placed under the underlined character.
All characters has the same width in my documents which makes it a bit
easier but still complicated.

I need this in order to convert documents to emulation program which does
not recognizes Word's underlines, therefore needs to use 'real' dashes under
the lines (instead of the 'space').

Thank you for your help.
 

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