Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-05-2022, 07:13 AM
Testeris Testeris is offline Make hyperlink in macro using Clipboard Windows 10 Make hyperlink in macro using Clipboard Office 2016
Novice
Make hyperlink in macro using Clipboard
 
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
Reply

Tags
getfromclipboard, hyperlink, macro error



Similar Threads
Thread Thread Starter Forum Replies Last Post
Make hyperlink in macro using Clipboard Copy Specific Text String To Clipboard At End Of Macro 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
Make hyperlink in macro using Clipboard How to extract selected hyperlink address to clipboard? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft