Reputation: 75
I'm writing some macro for MS Project. I have some URL string and string with text to display. I created hyperlink like:
wdDoc.Hyperlinks.Add Anchor:=Selection, Address:= _
urlString, SubAddress:= _
"", TextToDisplay:= _
displayText
So, how can I put this link into clipboard?
Upvotes: 0
Views: 937
Reputation: 75
This will work in MS Project with added MS Word Object Library
Dim hLink As Object
Dim wd As Object
Dim appWd As Word.Application
Dim strUrl, strName
Set strUrl = "mysite.com"
Set strName = "My hypelink to mysite.com"
'Create temp Word doc
Set appWd = CreateObject("Word.Application")
Set wdDoc = appWd.Documents.Add
Set hLink = wdDoc.Hyperlinks.Add(Anchor:=wdDoc.Range, _
Address:=strUrl, _
SubAddress:="", _
ScreenTip:="", _
TextToDisplay:=strName)
'text format
hLink.Range.Font.Name = "Segoe UI"
hLink.Range.Font.Size = 10
hLink.Range.Font.Color = RGB(0, 0, 255)
hLink.Range.Copy
Upvotes: 0
Reputation: 166790
Sub Tester()
Dim wdDoc, h, urlString, displayText
Set wdDoc = ActiveDocument
urlString = "http://google.com"
displayText = "google"
Set h = wdDoc.Hyperlinks.Add(Anchor:=Selection.Range, _
Address:=urlString, SubAddress:="", _
TextToDisplay:=displayText)
h.Range.Copy
End Sub
Upvotes: 0