【发布时间】:2014-07-10 23:48:55
【问题描述】:
我在 Visio 中有一个 VBA 代码,如果所述形状是超链接的,它将改变形状的颜色。现在,我使用一个简单的命令按钮来运行它。我希望宏在工作表中发生更改时运行。我知道在 excel 中如果我想这样做,我只需将我的代码放在 Workbook_Change 子中,但在 Visio 中我迷路了。
这是我当前的代码:
Private Sub CommandButton1_Click()
Dim Sh As Visio.shape
Dim Link As Hyperlink
For Each Sh In Visio.ActivePage.Shapes '<~ loop through the shapes collection
For Each Link In Sh.Hyperlinks '<~ loop through the links collection
If Not Link.Address = "" Then '<~ check for a blank address
Sh.Cells("Fillbkgnd").Formula = "RGB(255,102,0)"
Sh.Cells("Fillforegnd").Formula = "RGB(255, 102, 0)" '<~ apply a color to the shape
End If
Next Link
Next Sh
End Sub
有什么想法吗?
【问题讨论】: