Want Visio macro to toggle shape angle
I often will select a shape then go to the Size & Position box and change the angle from 0 to 90 or 90 to 0. This happens often enough that it seemed a good idea to have a macro to toggle the angle from one to the other. To that end I recorded a macro thinking I could look at the code and modify it to meet my needs. The code is below. What I found, though, was unlike anything I have seen in Excel or Access code and I am, once again, lost. Can anyone help? I would simply like to select an object and have its angle change from 0 to 90 or 90 to 0 when I click on the macro button which I would put on a toolbar.
Not being much of a code guy, I expect the logic would be to examine the object selected and if angle =0, change to 90 else change to 0. I just don't know how to write the code to do that. In the code below (from the recorded macro), I selected a rectangle, changed the angle to 90 then unselected it then selected it again and changed the angle the 0. I also wasn't sure where to save the recorded macro so I selected the active sheet although I would want it to be available in any Visio document I have open since I use it a lot for room layouts of furniture, machinery & equipment.
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Size & Position 2-D")
Application.ActiveWindow.Page.Shapes.ItemFromID(20).CellsSRC(visSectionObject, visRowXFormOut, visXFormAngle).FormulaU = "90 deg"
Application.EndUndoScope UndoScopeID1, True
Dim UndoScopeID2 As Long
UndoScopeID2 = Application.BeginUndoScope("Size & Position 2-D")
Application.ActiveWindow.Page.Shapes.ItemFromID(20).CellsSRC(visSectionObject, visRowXFormOut, visXFormAngle).FormulaU = "0 deg"
Application.EndUndoScope UndoScopeID2, True