Macro to bold and center the first line of each page.
Hi all,
Totally new to VBA but trying my best...I've searched for the answers but evidently dealing with pages is more challenging than I think it should be.
I have the following macro that bolds and centers the first line of the document, then goes through the first four pages of a document and selects and bolds the first line (which for me, is always a title). Then it goes back to the first page. So far it works great.
I believe a loop would be more efficient (especially since not every document is always four pages), but I'm failing miserably even getting started in building the loop. Can anyone help me turn what I have into a macro that loops through the document and bolds and centers the first line of each page? Thank you in advance!
Sub FirstLineCenter()
'
Dim ParaRange As range
Dim StartRange As range
Set StartRange = Selection.range
Set ParaRange = ActiveDocument.Paragraphs(1).range
ParaRange.Select
Selection.Font.Bold = True
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1
Set ParaRange = ActiveDocument.Bookmarks("\Page").range.Paragraphs (1).range
ParaRange.Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Font.Bold = True
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1
Set ParaRange = ActiveDocument.Bookmarks("\Page").range.Paragraphs (1).range
ParaRange.Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Font.Bold = True
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1
Set ParaRange = ActiveDocument.Bookmarks("\Page").range.Paragraphs (1).range
ParaRange.Select
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Font.Bold = True
Selection.HomeKey Unit:=wdStory
End Sub
|