Dingo
Dingo

Reputation: 123

Select the (ghost) shape hidden in Visio

I recently found out a new error coming up in my code and it seems to be coming because I did not account for a ghost shape (ID 231)

The ghost shape do not have master name or displayed text (as per shape report)

In this case, its hidden somewhere in my sheet/page. How do I select it via VBA by calling it using the specific ID?

If shape ID is this then bring it to forward and color it red would help (or purely to have it selected would help)

Thanks!

Upvotes: 1

Views: 1468

Answers (1)

JohnGoldsmith
JohnGoldsmith

Reputation: 2698

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

Note that the BringToFront method is also available on the Selection object so you could use it from there as well.

Upvotes: 4

Related Questions