I am parsing strings of characters; some are just plain old characters, while some are characters with a hyperlink.
The attached document holds such a string within a table cell.
Each character represents a "command", and I have to process each such command, hence in my document, there are six commands, two of which are hyperlinked ("B" and "C").
The VBA code works:-
Code: Select all
Sub test() Dim rng As Range Set rng = ThisDocument.Tables(1).Rows(1).Cells(1).Range Dim lng As Long For lng = 1 To rng.Characters.Count If rng.Characters(lng).Hyperlinks.Count = 0 Then Debug.Print "plain character " & rng.Characters(lng) Else Debug.Print rng.Characters(lng).Hyperlinks(1).TextToDisplay & rng.Characters(lng).Hyperlinks(1).Address End If Next lng End Sub
rng.Characters" was just my first thought.
There is no multi-million dollar contract riding on this; I am aware that my old FORTRAN skills are showing up, yet again.