Visio Guy

Visio Discussions => Programming & Code => Topic started by: jimmyhopps on August 07, 2012, 03:01:21 PM

Title: Change shape / geometry
Post by: jimmyhopps on August 07, 2012, 03:01:21 PM
Hi all.  wondering if anyone can help me with this basic question.

I am trying to change the outline of a basic shape in an org chart, by modifying its lines via the geometry section of the shape sheet.  I need to do this in code.  in the sample below, i'm trying to turn a box/rectangle into a triangle

using the macro recorder (ya i'm that basic), and some tweeks, i came up with the following: 


Sub ToTriangle()
    Dim ThisShape As Visio.Shape

       For Each ThisShape In Application.ActiveWindow.Selection
 
          If (ThisShape.Style <> "Connector") Then
            Application.ActiveWindow.Shape.CellsSRC(visSectionFirstComponent, 2, 0).FormulaU = "Width * 0.5"
            Application.ActiveWindow.Shape.CellsSRC(visSectionFirstComponent, 3, 1).FormulaU = "Height * 0"
            Application.ActiveWindow.Shape.DeleteRow visSectionFirstComponent, 4
        End If
       
    Next

End Sub


Title: Re: Change shape / geometry
Post by: Jumpy on August 07, 2012, 06:15:02 PM
First you should replace

Application.ActiveWindow.Shape.CellsSRC.....

with

ThisShape.CellsSRC...

as that is the shape you want to change.
Browser ID: smf (is_webkit)
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 1: index+Modifications.english (default).
Style sheets: 0: .
Hooks called: 44 (show)
Files included: 25 - 925KB. (show)
Memory used: 767KB.
Tokens: post-login.
Cache hits: 7: 0.00098s for 22,301 bytes (show)
Cache misses: 1: (show)
Queries used: 9.

[Show Queries]