Thread: Word VBA Help
View Single Post
 
Old 06-06-2019, 12:06 PM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Danny,


I'm not going to give you the whole fish and this is a bit clunky, but you can use selection and the wdLine unit to get this started:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Range
Dim lngCount As Long
Dim bExit As Boolean
  Set oRng = ActiveDocument.Range
  oRng.Collapse wdCollapseStart
  Application.ScreenUpdating = False
  oRng.Select
  On Error GoTo Err_Exit
  Selection.MoveDown wdLine, 2
  Selection.Bookmarks("\line").Select
  Selection.Range.HighlightColorIndex = wdBrightGreen
  Selection.Collapse wdCollapseEnd
  Do
    lngCount = 0
    Do
      Selection.MoveDown wdLine, 1
      lngCount = lngCount + 1
      Selection.Bookmarks("\line").Select
      If Selection.Range.End + 1 = ActiveDocument.Range.End Then bExit = True
      If bExit Then Exit Do
    Loop
    If lngCount = 2 Then
      Selection.Range.HighlightColorIndex = wdBrightGreen
      Selection.Collapse wdCollapseEnd
    End If
    If bExit Then Exit Do
  Loop
lbl_Exit:
  Application.ScreenUpdating = True
  Exit Sub
Err_Exit:
  Resume lbl_Exit
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote