Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract links from word (gray hyperlinks) 1

Status
Not open for further replies.

knownote

Technical User
Feb 29, 2004
98
US
I usually save to notepad or Access, but Tweets require Word to see gray hyperlinks, which must be separately selected between double quotes from within Hyperlink tag.
(Not a Programmer nor write code.)

Instead of extracting only links in wrong order to a new doc ..

Below code (I changed) extracts/inserts link before gray hyperlink, inplace within tweet, within current document. (Inserting after gray hyperlink makes extracted link gray also).

Question:
It's 99% there, but how to also extract date and time along with status url?

{HYPERLINK " \o "7:27 AM - 26 Nov 2019" }
Tweet message.

Word macro code:

Sub HlinkChanger()
Dim oRange As Word.Range
Dim oField As Field
Dim link As Variant
With ActiveDocument
' .Range.AutoFormat '(orig) I commented out
For Each oRange In .StoryRanges
For Each oFld In oRange.Fields
If oFld.Type = wdFieldHyperlink Then
For Each link In oFld.Result.Hyperlinks
oFld.Select
Selection.InsertBefore (" (" + link.Address + ") ") '(orig) InsertAfter
'Selection.InsertBefore (" (" + link.Address & " " & link.SubAddress + ") ")
Next link
End If
Next oFld
Set oRange = oRange.NextStoryRange
Next oRange
End With
End Sub
 
One way:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim hLnk As Hyperlink
With ActiveDocument
  For Each hLnk In .Hyperlinks
  .Range.InsertBefore Trim(Replace(Split(hLnk.Range.Fields(1).Code.Text, "HYPERLINK")(1), Chr(34), "")) & vbCr
  Next
End With
Application.ScreenUpdating = True
End Sub

Cheers
Paul Edstein
[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top