Visio Guy

Visio Discussions => Visio 2013 Issues => Topic started by: JuneTheSecond on August 24, 2013, 11:42:28 AM

Title: Macro rel to abs and reverese formulas in Geometry Section
Post by: JuneTheSecond on August 24, 2013, 11:42:28 AM
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 Explicit

Sub 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 Igeo

End 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 Igeo

End Sub


However I think the best way is Visio has the menu to convert rel to abs or reverse.  :)