View Single Post
 
Old 08-15-2019, 04:44 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

Something like this:


Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim varFactors
Dim lngIndex As Long
Dim strFind As String
Dim oRng As Range
  varFactors = Split(Selection.Text, ",")
  For lngIndex = 0 To UBound(varFactors)
    strFind = InputBox("Enter the string to find.")
    Set oRng = ActiveDocument.Range
    With oRng.Find
      .Text = strFind
      .MatchCase = True
      If .Execute Then
        'If you need to expand the range of the defined text do it here before applying the BM
        oRng.Bookmarks.Add Trim(varFactors(lngIndex)), oRng
      End If
    End With
  Next
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote