View Single Post
 
Old 11-05-2022, 07:13 AM
Testeris Testeris is offline Windows 10 Office 2016
Novice
 
Join Date: Nov 2022
Posts: 8
Testeris is on a distinguished road
Default

Great, this part worked! So now, how to put it on the text needed?

When I insert the code into my macro, it still overlays on the URL text.
Is it HomeKey that shows the insert location? (Sorry, I know I am wondering in the mist)
This is how it looks in my macro: Imgur: The magic of the Internet
The code so far:
Sub aOverlayHTMLDecharges()
'
' aOverlayHTMLDecharges Macro
'
Dim MyData As DataObject
Dim strAddr As String
Dim strTitle As String
Set MyData = New DataObject
' Dim clipboard As MSForms.DataObject
' Set clipboard = New MSForms.DataObject
Dim oRng As Range
Dim sLink As String
' On Error Resume Next

Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdParagraph, Count:=9
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
' cut the link text
' Selection.Copy
' Selection.Cut

' here?
Selection.HomeKey
Set oRng = Selection.Paragraphs(1).Range
oRng.End = oRng.End - 1
sLink = oRng.Text

' oRng.Hyperlinks.Add oRng, sLink



' clipboard.SetText Selection.Hyperlinks(1).Address
' clipboard.PutInClipboard

' MyData.GetFromClipboard '<-- not sure where in the code to put it
' strAddr = MyData.GetText

' selecting the location where to overlay - TO MODIFY
Selection.MoveLeft Unit:=wdCharacter, Count:=2
Selection.MoveLeft Unit:=wdWord, Count:=9, Extend:=wdExtend

' sub to put in the hyperlink -->
MyData.GetFromClipboard
strAddr = MyData.GetText

' What to do with these? Which one on the new selection?
oRng.Hyperlinks.Add oRng, sLink
' ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:=strAddr, SubAddress:="", ScreenTip:="", TextToDisplay:=Selection.Range

' End of the insert

' return to the beginning of the page and/or continue to other macto
Selection.HomeKey Unit:=wdStory
End Sub
Reply With Quote