Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shape Selection

Status
Not open for further replies.

ChiliDog007

Technical User
Sep 20, 2004
24
US
is there a way to select shapes from VB6 and group them?
 
Loop through the shapes, selecting those you want as you go, then use the Group method. Here is a quick'n'dirty macro to group shapes numbered 7, 8 and 9:
Code:
Sub macro1()
With ThisDocument.Pages("Page-1")
For Each x In .Shapes
y = Right(x.Name, Len(x.Name) - InStrRev(x.Name, "."))
Select Case y
Case 7, 8, 9
ActiveWindow.Select x, visSelect
End Select
Next
ActiveWindow.Group
End With
End Sub

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
thanx for the quick reply. i'll try and adapt this accordingly
 
What do i put for x?
For Each x In .Shapes
i see what y does but i am unsure of how to declare x
 
i got this error, do i need to add a library or something?
ERROR
ActiveX component cant create object
 
Sorry I assumed that you'd got the coding started.

You'll need a reference to the Visio Type Library for your version of Visio.

x is a reference to a Visio Shape object:


You need a bit more for your declarations bit in VB6. Try:
Code:
Private Sub Command1_Click()
Dim visApp As Visio.Application
Dim visDoc As Visio.Document
Dim x As Visio.Shape
Dim y As Integer
Set visApp = New Visio.Application
Set visDoc = visApp.Documents.Open("c:\test.vsd")
    visApp.Visible = True
    Set visPage = visDoc.Pages.Item(1)
With visPage
For Each x In .Shapes
y = Right(x.Name, Len(x.Name) - InStrRev(x.Name, "."))
Select Case y
Case 7, 8, 9
visApp.ActiveWindow.Select x, visSelect
End Select
Next
visApp.ActiveWindow.Group
End With

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
oh i see now what the problem was,
visApp.ActiveWindow.Group
i wasn't using the visioapplication to select them. thanx a whole lot man.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top