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.

What I find is that the IF statement always resolves to false and the ELSE is executed. In other words, if my selected shape is at 0 then it will toggle to 90. However, if the shape is 90, it will not go to 0.

Try a debug line to see what the value of .formula is. In front of the If statement add this line
Debug.print .Formula

Then show your immediate window (Ctrl-G) and run the code. What is the value shown in the immediate window?

Have you also tried the alternate one line code I offered? I thought this would be better for floor layouts since it gives you four directions rather than two.

1) The one line of code works well and I have it as a rotate macro... the other is just a fast toggle when I work with rectangular objects (shapes).

2) I did the debug thing as you suggested and found that the value of .formula was '0 deg.' NOTE the period at the end of deg. So, I changed the macro to include a period after every instance of deg and it works fine now.

3) Many thanks to you for this. Now, if I can figure out how to have a button on the tool bar to which I can assign the macro. I can only get one button that shows a dropdown with all the macros.

Perhaps I'm missing something here, but Visio has a tool for rotating 90 degrees clockwise and another for counter clockwise. It's in the Actions toolbar that you can activate by right clicking in the toolbar area. Unless there's a requirement I'm not inferring from the description, writing code for this is like killing a fly with a hammer. With the Actions toolbar you get the feature and the tool icons.