![]() |
|
#1
|
|||
|
|||
![]()
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 |
![]() |
Tags |
getfromclipboard, hyperlink, macro error |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
et_33 | Excel Programming | 8 | 10-11-2022 06:24 AM |
WORD MACRO COPY/PAST from clipboard | rachidlea | Word VBA | 0 | 11-16-2021 09:38 AM |
Macro for copying in clipboard more than one selected text | ghostwhisperer86 | Outlook | 0 | 03-31-2019 07:47 AM |
![]() |
poetofpiano | Word VBA | 8 | 02-18-2018 07:17 PM |
Add Hyperlink in Visio that when clicked copies something to your clipboard | MoHyB | Visio | 0 | 11-10-2017 08:55 AM |