Group shapes selection error

A

Asif

Hi all,

I am using Visio 2003 Active X control in Process Mapping application.
I am using grouping and ungrouping shapes by selecting and deselecting
shapes.

It is working fine for single shapes but once I select the shape that
is grouped shape it gives the following error message

Inappropriate Target Object for this Action

I am using VisSelectArgs.visSelect as select action attribute in
ActiveWindow.Select method, it now allow selecting shape but
ungroup/detach the child shape of selected shape (Parent Shape).

Is there any way to first select Group shape, ungroup and regroup it
without leaving child shapes of that group shape?

Thanks a lot

Asif
 
A

Asif

JuneTheSecond said:
Did you try to deselect all before select new shape?

Hi June

Yes I also did it but it does not work. I am using the following code
for selection

Private Sub SelectShape(ByVal objShape As Shape)

objShape.Application.ActiveWindow.DeselectAll()
If objShape.Parent.Type = VisShapeTypes.visTypeGroup Then
objShape.Application.ActiveWindow.Select(objShape,
VisSelectArgs.visSubSelect)
Else
objShape.Application.ActiveWindow.Select(objShape,
VisSelectArgs.visSelect)
End If

End Sub

Can you please tell me whets wrong in it?

Thanks

Asif
 
J

JuneTheSecond

Your code is completely right.
The shape is really selected, but it is not shown on the wondow.
If you print out Selection(1).Name, it gives the name of the shape.
It might be a bug of drawing control.
 
J

JuneTheSecond

I am sorry I made some mistake.
Your code works well, if it si written as

Private Sub TestToolStripMenuItem_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TestToolStripMenuItem.Click
Dim objShape As Microsoft.Office.Interop.Visio.Shape
objShape = AxDrawingControl1.Document.Application.ActivePage.Shapes(1)
SelectShape(objShape)
End Sub

Private Sub SelectShape(ByVal objShape As
Microsoft.Office.Interop.Visio.Shape)

objShape.Application.ActiveWindow.DeselectAll()
If objShape.Parent.Type =
Microsoft.Office.Interop.Visio.VisShapeTypes.visTypeGroup Then
objShape.Application.ActiveWindow.Select(objShape,
Microsoft.Office.Interop.Visio.VisSelectArgs.visSubSelect)
Else
objShape.Application.ActiveWindow.Select(objShape,
Microsoft.Office.Interop.Visio.VisSelectArgs.visSelect)
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top