Re: Bold every second line



Thanks Macropod,
Very helpful

"macropod" wrote:

Hi Kanga,

In case you've got line-feeds at the end of each logical line, try something along the lines of:

Sub LineFormatter()
Dim oRng As Range
Dim i As Long
With ActiveDocument
With .Content.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^l"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
For i = 1 To .Paragraphs.Count
If i Mod 2 = 0 Then
.Paragraphs(i).Range.Bold = True
Else
.Paragraphs(i).Range.Bold = False
End If
Next i
With .Content.Find
.Text = "^p"
.Replacement.Text = "^l"
.Execute Replace:=wdReplaceAll
.Text = "^l^p"
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
End With
End Sub

--
Cheers
macropod
[MVP - Microsoft Word]


"Kanga 85" <Kanga85@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:B5329F24-1109-4E7A-AA17-B37D3E25F855@xxxxxxxxxxxxxxxx
Thanks Graham,
I actually want lines rather than paragraphs, but I should be able to modify
your macro (or my docu,ment).

"Kanga 85" wrote:

I have a long list, and would like to bold every second line of the whole
document. I need a macro because new entries will be inserted at various
points and so muck up any original formatting.

Thanks in advance,

.



Relevant Pages

  • RE: search only the words within a selection
    ... selection/highlighted text/paragraph of a document only? ... the macro will search for the word ... Dim oRng As Range ... Do While .Execute ...
    (microsoft.public.word.vba.general)
  • Re: Bold every second line
    ... Dim oRng As Range ... .MatchWholeWord = False ... .Execute Replace:=wdReplaceAll ... I need a macro because new entries will be inserted at various points and so muck up any original formatting. ...
    (microsoft.public.word.vba.general)
  • Re: Macro to unprotect, refresh and proetct
    ... "macropod" wrote: ... The macro goes in the workbook's 'ThisWorkbook' module, ... unprotects a single worksheet - you'll need to add more code if there are more worksheets to unprotect. ... Dim wks As Worksheet ...
    (microsoft.public.word.vba.general)
  • Re: One more question
    ... an equivalent for paragraph page break. ... Style solution for now unless I can figure out a true macro. ... Dim oRng As Word.Range ... Set oRng = ActiveDocument.Range ...
    (microsoft.public.word.vba.general)
  • Re: Setting Decimal Places in a Word Table
    ... I believe that macropod has gone off on a road trip so he might not be back here for a while. ... a macro can only work on a contiguous range and that is the reason that it only affects the first of the selected cells. ... 'check that the selection is in a table ...
    (microsoft.public.word.vba.general)