Macro rel to abs and reverese formulas in Geometry Section

Started by JuneTheSecond, August 24, 2013, 11:42:28 AM

0 Members and 1 Guest are viewing this topic.

JuneTheSecond

In Visio 2013 Visio makes sometimes relative formula in geometry section.
If you feel them not convinient, you can convert the formula to absolute formulas by saveing the drawing as Visio 2007 or old version and open again the saved drawing.
If you feel still not convient, you can directly convert the formulas with simple macro.

This is a macro to convert relative formulas to absolute formula.

`Option ExplicitSub Rel2AbsRows()    Dim shp As Visio.Shape    Dim Irow As Long    Dim Nrow As Long    Dim Igeo As Long    Dim Ngeo As Long        Set shp = ActiveWindow.Selection(1)        Ngeo = shp.GeometryCount - 1        If Ngeo < 0 Then Exit Sub        For Igeo = 0 To Ngeo            Nrow = shp.RowCount(visSectionFirstComponent + Igeo) - 1                For Irow = 1 To Nrow            If shp.RowType(visSectionFirstComponent + Igeo, 1) = visTagRelMoveTo Then                shp.RowType(visSectionFirstComponent + Igeo, 1) = visTagMoveTo            ElseIf shp.RowType(visSectionFirstComponent + Igeo, Irow) = visTagRelLineTo Then                shp.RowType(visSectionFirstComponent + Igeo, Irow) = visTagLineTo            ElseIf shp.RowType(visSectionFirstComponent + Igeo, Irow) = visTagRelEllipticalArcTo Then                shp.RowType(visSectionFirstComponent + Igeo, Irow) = visTagEllipticalArcTo            End If        Next Irow            Next IgeoEnd Sub`

This is a macro to convert absplute formulas to relative.

`Sub AbsRows2Rel()    Dim shp As Visio.Shape    Dim Irow As Long    Dim Nrow As Long    Dim Igeo As Long    Dim Ngeo As Long        Set shp = ActiveWindow.Selection(1)        Ngeo = shp.GeometryCount - 1        If Ngeo < 0 Then Exit Sub        For Igeo = 0 To Ngeo            Nrow = shp.RowCount(visSectionFirstComponent + Igeo) - 1                For Irow = 1 To Nrow            If shp.RowType(visSectionFirstComponent + Igeo, 1) = visTagMoveTo Then                shp.RowType(visSectionFirstComponent + Igeo, 1) = visTagRelMoveTo            ElseIf shp.RowType(visSectionFirstComponent + Igeo, Irow) = visTagLineTo Then                shp.RowType(visSectionFirstComponent + Igeo, Irow) = visTagRelLineTo            ElseIf shp.RowType(visSectionFirstComponent + Igeo, Irow) = visTagEllipticalArcTo Then                shp.RowType(visSectionFirstComponent + Igeo, Irow) = visTagRelEllipticalArcTo            End If        Next Irow            Next IgeoEnd Sub`

However I think the best way is Visio has the menu to convert rel to abs or reverse.
Best Regards,

Junichi Yoda
http://june.minibird.jp/