gpt4 book ai didi

excel - `Range.Hyperlink.Shape` 有什么作用?

转载 作者:行者123 更新时间:2023-12-04 09:40:00 24 4
gpt4 key购买 nike

我明白,Shape.Hyperlink是与形状相关的超链接,Shape.Hyperlink.Follow在网络浏览器中打开并显示超链接,就像我左键单击形状一样。

问:但是 Range.Hyperlink.Shape 是什么意思?做,当我给它分配一些形状时?

它似乎是与超链接相关的形状......

当我将鼠标悬停在超链接的文本或其他内容上时,它会弹出形状吗?

对于加里的:

Sub DummySub(rng As Range, shp As Shape)               
rng.Hyperlinks.Add rng, "http://microsoft.com", "", "Hint"
rng.Hyperlinks(1).Shape = shp
End Sub

最佳答案

对于薄片形状,您可以添加 Link .右键单击它或在 VBA 代码中。您可以选择Existing file or web Page , Place in this Document , Create new DocumentE-mail-Address .

如果您选择“现有文件或网页”并为其提供网页地址,它将成为一个超链接。

但是Range.Hyperlink.Shape在VBA中没有意义,恐怕......
Hyperlink VBA 中不存在范围属性。仅限 Hyperlinks . Hyperlink.Shape是的...

请测试下一个代码:

Sub testRangeHiperlynk()
Dim HypShape As Shape

Set HypShape = ActiveSheet.Shapes.AddShape(msoShapeRoundedRectangle, 300, 160, 100, 20)
HypShape.Name = "testRect"
HypShape.TextFrame.Characters.text = "Go to Google"
ActiveSheet.Hyperlinks.aDD Anchor:=HypShape, address:="http://www.google.com", SubAddress:="GoToGoogle!A1"
Debug.Print ActiveSheet.Shapes("testRect").Hyperlink.Shape.Name
ActiveSheet.Shapes("testRect").Hyperlink.Shape.Fill.ForeColor.RGB = RGB(255, 0, 0)
End Sub

它创建一个矩形,将其命名为“textRect”,在上面写一些东西,然后在 A1 中创建一个(某种)超链接,但引用新创建的形状,定位 Google.com .

那就看看 HypShape.Hyperlink.Shape.Name在立即窗口中返回以及如何使用 Hyperlink.Shape.Fill 定义形状已经上色了……

但是 Range.Hyperlink.Shape在 VBA 中不存在 :)

编辑:该属性可以更聪明地使用。运行此代码(在第一个代码之后),您将能够根据工作表超链接设置形状:
Sub testHypShape()
Dim H As Hyperlink, sh As Shape
For Each H In ActiveSheet.Hyperlinks
If H.Shape.Name = "testRect" Then Set sh = H.Shape: Exit For
Next
sh.Fill.ForeColor.RGB = RGB(0, 225, 225)
End Sub

关于excel - `Range.Hyperlink.Shape` 有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62376315/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com