Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

don't add return if there already is one (so there aren't 2)

Status
Not open for further replies.

NetCow

Technical User
Oct 17, 2008
2
US
Code:
' If Subhead
        ElseIf Selection.Text <> " " And Selection.Font.Size = 10 And 
Selection.Font.Bold = True Then
         ' Tag Subhead
            Selection.EndKey Unit:=wdLine
            Selection.TypeText Text:="#####"
            Selection.HomeKey Unit:=wdLine
            Selection.TypeText Text:="#####"
            Selection.HomeKey Unit:=wdLine
            Selection.MoveDown Unit:=wdLine, Count:=1
         **Selection.TypeParagraph 
            Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
        Else
            Selection.MoveDown Unit:=wdParagraph, Count:=1
            Selection.HomeKey Unit:=wdLine
            Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
        End If
    Wend
  ' Remove # and add line
    Selection.TypeParagraph
** If there is already a 'blank line' next after the 'subhead'(just a paragraph mark) I do not want this paragraph return added. I only want one added when a line of text follows a 'subhead'. please oh please oh please can you help me? i am going mad
 
You should learn to use Styles, and not use empty paragraphs to make blank lines. You should also try to avoid using Selection, but, to answer your question, if the Selection is in your 'SubHead' then one way would be along these lines:

Code:
[blue]With Selection.Paragraphs.Last.Next.Range
    If .Characters.First <> .Characters.Last Then .InsertParagraphBefore
End With[/blue]

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
I agree, there are WAY better ways to do what is being done, but my hands are tied. Thank you _so much_ for this, it will help ease my utter frustration with the "we're happy rubbing sticks to make our fire, we don't want none of that flint stuff" attitude i live with everyday.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top