Shapes.CenterDrawing method to a group

J

JuneTheSecond

Shapes.CenterDrawing method has no effect to group's shapes.
Is it a feature, or am I making any mistake? Visio 2003 and 2007.
 
J

JuneTheSecond

An alternative might be a macro like below.

Sub test()
'
' ActivePage.Shapes(1).Shapes.CenterDrawing
' does not work at all to group's shapes.
' This macro is an alternative to center in the group.

Dim shp As Visio.Shape
Set shp = ActivePage.Shapes(1)
CenterGroup shp
End Sub
Sub CenterGroup(shp As Visio.Shape)
If Not shp.Type = visTypeGroup Then Exit Sub
Dim mySelection As Visio.Selection
Dim shpChild As Visio.Shape
Dim x As Double, y As Double
Dim shpRegion As Visio.Shape
For Each shpChild In shp.Shapes
ActiveWindow.Select shpChild, visSubSelect
Next
Set mySelection = ActiveWindow.Selection
Set shpRegion = mySelection.DrawRegion(0, 0)
x = shpRegion.Cells("PinX")
y = shpRegion.Cells("Piny")
shpRegion.Delete
mySelection.Move shp.Cells("PinX") - x, shp.Cells("PinY") - y

ActiveWindow.DeselectAll
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