View Single Post
 
Old 01-05-2025, 02:07 PM
gmaxey gmaxey is offline Windows 10 Office 2019
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

Perhaps something like this:


Code:
Option Explicit
Sub YourLargerMacro()
  If fcnXorY Then
    MsgBox "Do x"
  Else
    MsgBox "Do y"
  End If
lbl_Exit:
  Exit Sub
End Sub
Function fcnXorY() As Boolean
'A basic Word Macro coded by Gregory K. Maxey
Dim oRngStart As Range, oRng As Range
Dim bDo_x As Boolean
  bDo_x = False
  Set oRngStart = Selection.Range
  Set oRng = ActiveDocument.Bookmarks("\Page").Range
  With oRng.Find
    .Text = "^m"
    If .Execute Then
      bDo_x = True
    Else
      With oRng.Find
        .Text = "^b"
        Do While .Execute
          oRng.Collapse wdCollapseEnd
          oRng.Select
          If Selection.Sections(1).PageSetup.SectionStart <> wdSectionContinuous Then
            bDo_x = True
            Exit Do
          End If
        Loop
      End With
    End If
  End With
  oRngStart.Select
lbl_Exit:
  Exit Function
End Function
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote