I am trying to select all the text under a subheading inside a table cell in Microsoft Word. It is working fine when there is a subheading after the text, but if it is the last subheading in the cell it selects the whole cell. Is there a way to check Selection.Next for the end of the cell?
Here is my code so far:
Public Sub copySubHeading()
Selection.HomeKey Unit:=wdStory
With Selection.Find
.ClearFormatting
.MatchCase = False
.Text = "Example:"
.Wrap = wdFindContinue
.Font.Bold = True
.Execute
End With
Selection.MoveRight Unit:=wdCell, Count:=1, Extend:=wdMove
With Selection.Find
.ClearFormatting
.MatchCase = False
.Text = "Heading 6:"
.Wrap = wdFindContinue
.Font.Bold = True
.Execute
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdMove
While IsAlphanumericCharacter(Selection) <> True
Selection.Next(Unit:=wdCharacter, Count:=1).Select
Wend
While Not Selection.Next.Bold
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Wend
End Sub
Private Function IsAlphanumericCharacter(character As String) As Boolean
Select Case Asc(character)
Case 48 To 57, 65 To 90, 97 To 122
IsAlphanumericCharacter = True
Case Else
IsAlphanumericCharacter = False
End Select
End Function
This code above will work when the cell ends with whatever this special character is in the picture below, although the cells I have to work with do not end with this character every time.
Most time the cell will end with the character at the end of the cell below.

Is there a way to select the text until either a bold character or the end of the cell?
Or if someone can offer a better way to select all the text until the next heading that would be very helpful, thanks.