find bold headings and add a return(or tab) after it

B

Baher

have a document like this...

1.0 Introduction(this is bold). Welcome to my document(first sentance of a
pragraph that isnt bolded text).

I need to put a return or a tab after the heading stuff thats in bold. Note
that some tables have bold headings centered on the page so perhaps a
condtion needed in the code to test for end of line(or text thats centered)
so it will skip that stuff

i have this from another post i found so maybe you VBA folks will have a
starting point to play with to help me out..thanks!

Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
'**********************
.Text = "text" 'put your searched text here
.Replacement.Text = "^&"
.Replacement.Font.Underline = True
.Replacement.Font.Bold = True
'**********************
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
End With
Selection.Find.Execute replace:=wdReplaceAll
 
B

Baher

well i got it to work but i've come to find out an edit-find/replace would
have done the job just as well it seems...here's the code anyway...

Private Sub find_replace()
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
'**********************
.Font.Bold = True
.Replacement.Text = "^&" & vbCrLf
'.Replacement.Font.Underline = True
'.Replacement.Font.Bold = True
'**********************
.Forward = True
.Wrap = wdFindContinue
.Format = True
' .MatchCase = False
' .MatchWholeWord = False
' .MatchAllWordForms = False
' .MatchSoundsLike = False
' .MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
 

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