Select Visio 中隐藏的(幽灵)形状

Select the (ghost) shape hidden in Visio

我最近发现我的代码中出现了一个新错误,它似乎会出现,因为我没有考虑幽灵形状 (ID 231)

幽灵形状没有主名称或显示文本(根据形状报告)

在这种情况下,它隐藏在我的某个地方 sheet/page。我如何通过 VBA 通过使用特定 ID 调用它来 select 它?

如果形状 ID 是这个,那么将它移到前面并将其着色为红色会有所帮助(或者纯粹将其 selected 会有所帮助)

谢谢!

Sub SetHiddenShape()
  Dim vPag As Visio.Page
  Dim vShp As Visio.Shape

  'Assumes target page is activepage (which might not be the case)
  Set vPag = ActivePage
  Set vShp = vPag.Shapes.ItemFromID(231)
  vShp.BringToFront
  vShp.CellsU("FillForegnd").FormulaU = "=RGB(200, 50, 50)"

  'and to select the the shape:
  ActiveWindow.Select vShp, VisSelectArgs.visDeselectAll + VisSelectArgs.visSelect
End Sub

请注意,BringToFront 方法也可用于 Selection 对象,因此您也可以从那里使用它。