J
John Sheppard
Excuse me if this question has been answered, but I've looked and if
there is an answer, I'm not finding it.
I'm trying to use VBA in Visio to access shapes on a page. It looks
like I have to define both a collection of shapes and an individual
shape object. As I use these objects in my code, it looks like I have
to set my individual shape object with a reference to the index of a
shape in the collection of shapes. So far, I'm okay with this,
however...
It looks like the only way to create all the shape objects in the
collection is to either start by selecting them before running the
macro OR creating them as part of the code, as is shown in this
example...
'This Microsoft Visual Basic for Applications (VBA) macro
'demonstrates selecting, deselecting, and subselecting shapes.
Public Sub Select_Example ()
Const MAX_SHAPES = 6
ReDim shpObjs(1 To MAX_SHAPES) As Visio.Shape
Dim i As Integer
Dim shpObj As Visio.Shape
'Draw some shapes.
For i = 1 To MAX_SHAPES
Set shpObjs(i) = ActivePage.DrawRectangle(i, i + 1, i + 1, i)
Next i
ActiveWindow.DeselectAll
For i = 1 To 3
ActiveWindow.Select shpObjs(i), visSelect
Next i
<snip>
I don't want to do either one of these. I what I want is to be able to
reference the shapes by their ID number.
I want to be able to say that shpObj = activePage.item(shapeID)...or
something like that. I just can't figure out if that's possible, and
if so how you do it.
Any help is much appreciated. Thanks!
there is an answer, I'm not finding it.
I'm trying to use VBA in Visio to access shapes on a page. It looks
like I have to define both a collection of shapes and an individual
shape object. As I use these objects in my code, it looks like I have
to set my individual shape object with a reference to the index of a
shape in the collection of shapes. So far, I'm okay with this,
however...
It looks like the only way to create all the shape objects in the
collection is to either start by selecting them before running the
macro OR creating them as part of the code, as is shown in this
example...
'This Microsoft Visual Basic for Applications (VBA) macro
'demonstrates selecting, deselecting, and subselecting shapes.
Public Sub Select_Example ()
Const MAX_SHAPES = 6
ReDim shpObjs(1 To MAX_SHAPES) As Visio.Shape
Dim i As Integer
Dim shpObj As Visio.Shape
'Draw some shapes.
For i = 1 To MAX_SHAPES
Set shpObjs(i) = ActivePage.DrawRectangle(i, i + 1, i + 1, i)
Next i
ActiveWindow.DeselectAll
For i = 1 To 3
ActiveWindow.Select shpObjs(i), visSelect
Next i
<snip>
I don't want to do either one of these. I what I want is to be able to
reference the shapes by their ID number.
I want to be able to say that shpObj = activePage.item(shapeID)...or
something like that. I just can't figure out if that's possible, and
if so how you do it.
Any help is much appreciated. Thanks!