将一些超链接放入剪贴板 (VBA)
Put into clipboard some hyperlink (VBA)
我正在为 MS Project 编写一些宏。我有一些 URL 字符串和要显示的文本字符串。
我创建了 hyperlink 就像:
wdDoc.Hyperlinks.Add Anchor:=Selection, Address:= _
urlString, SubAddress:= _
"", TextToDisplay:= _
displayText
那么,如何将这个 link 放入剪贴板?
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
这将在添加了 MS Word 对象库的 MS Project 中工作
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
我正在为 MS Project 编写一些宏。我有一些 URL 字符串和要显示的文本字符串。 我创建了 hyperlink 就像:
wdDoc.Hyperlinks.Add Anchor:=Selection, Address:= _
urlString, SubAddress:= _
"", TextToDisplay:= _
displayText
那么,如何将这个 link 放入剪贴板?
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
这将在添加了 MS Word 对象库的 MS Project 中工作
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