在microsoft excel vba中,我试图为我绘制的形状分配超链接和/或动作。这大致是我尝试过的(一次只取消一行)
基本上,我想要做的是通过点击形状对象让用户获得更多信息。超链接很好,但某种接受参数的事件处理程序是理想的。我将创建数百个这些形状,并且需要链接到文档中的唯一位置。
Dim destinationHyperlinkCell as Range
set destinationHyperlinkCell = Range("10:10")
' (do some stuff here)...
With Sheet1.Shapes.AddTextbox(msoTextOrientationHorizontal, _
600, _
600, _
300, _
16)
.TextFrame.Characters.Text = "Test this thing"
.Name = destinationHyperlinkCell.Address & " group of shapes"
'.Hyperlink.Address = destinationHyperlinkCell.Address
'.Hyperlink.Range = destinationHyperlinkCell.Address
'.OnAction = "'showDebugMsg """ & .Name & """'"
End With
答案 0 :(得分:1)
使用“指定宏...”为每个在“点击”
上触发的形状定义一个宏您可以为每个形状使用相同的宏,并使用Application.Caller
属性获取触发宏的形状的名称。然后你就拥有了编写智能处理程序的所有成分 - 就像一个(隐藏的)Excel表格,可以将形状名称解析为URL,文本或其他
Sub Shape_Click()
MsgBox "Co-Cooo! from" & Application.Caller
End Sub
希望有所帮助
祝你好运 - MikeD