![]() |
#1
|
|||
|
|||
![]()
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 |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to make a LINE BOLD under cursor | Retko | Word VBA | 4 | 01-28-2022 03:38 AM |
![]() |
DiGug | Word | 3 | 10-02-2014 02:43 PM |
Format Bold in one line makes all lines bold | Nitte | Word | 2 | 02-07-2013 12:34 AM |
How to Center One Line Vertically on Blank Page | SQLUSA | Word | 1 | 08-29-2012 08:14 PM |
Macro that will go to line # and center text | marge | Word VBA | 0 | 09-10-2010 12:30 PM |