![]() |
|
|
|
#1
|
|||
|
|||
|
Here is my final code.
The user selects text in the Word document. ALL hyperlinks within the text of ALL endnotes that are encountered, are opened through a Chrome browser. Thanks for the support. Code:
Sub Demo()
'https://www.msofficeforums.com/word-vba/50191-get-only-endnotes-selected-text.html
Dim Rng As Range
Dim hl As Hyperlink
Const chromeFileLocation As String = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
Application.ScreenUpdating = False
With Selection
Set Rng = .Range
' If nothing is selected, show a message
If .Start = .End Then
MsgBox "Please make a selection containing 1 or more endnotes."
Application.ScreenUpdating = True
Exit Sub
End If
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Format = False
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = False
.Text = "^e"
End With
Do While .Find.Execute
If Not .InRange(Rng) Then Exit Do
For Each hl In .Endnotes(1).Range.Hyperlinks
'Debug.Print e.Index & ": " & hl.Address
Shell (Chr(34) & chromeFileLocation & Chr(34) & "-url " & hl.Address)
Next
.Collapse wdCollapseEnd
Loop
Rng.Select
End With
Application.ScreenUpdating = True
End Sub
|
|
| Tags |
| endnote reference |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Footnote formatting>"Apply changes to selected text" not limiting changes to selected text
|
Swarup | Word | 11 | 07-26-2022 01:51 PM |
Find and Replace Selected Text or Macro for finding selected text
|
mrplastic | Word VBA | 4 | 12-20-2019 01:25 PM |
| Powerpoint-2019 Text in selected theme remains in All Caps even when small caps option is selected | Tanasha4 | PowerPoint | 2 | 04-06-2019 07:53 PM |
How to convert endnotes in a text doc to Word endnotes?
|
Dickison | Word VBA | 4 | 10-06-2012 09:11 PM |
Separating endnotes from text
|
kenglade | Word | 22 | 09-14-2012 04:10 PM |