News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Macro rel to abs and reverese formulas in Geometry Section

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

Previous topic - Next topic

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 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.  :)
Best Regards,

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

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 143 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1055KB.
Tokens: post-login.
Cache hits: 14: 0.00208s for 26,724 bytes (show)
Cache misses: 4: (show)
Queries used: 17.

[Show Queries]