Question

I'm developing an Excel Add-In using VSTO, and one of the reports the tool generates has a SmartArt as output. Right now the output is:

wrong direction

And I want the output to be:

right direction

I know that Excel has this command, that does exactly it:

right to left

But I can't access this with VBA or C#.

Thanks in advance for the help!

Was it helpful?

Solution

I believe you need to have office 2010 or 2013 to do this.

I used code to obtain the name of the diagram (in my case, 'Diagram 1') from:

http://www.ozgrid.com/VBA/shapes.htm (although I imagine you can find a better method)

Then slightly modified the code from:

http://social.msdn.microsoft.com/Forums/office/en-US/b6af1478-045b-40b1-b05c-2cb95aa2127e/excel-2007-smart-art-manipulate-text-using-vba?forum=exceldev

Sub test()
    Dim sh As Shape
    Dim sa As SmartArt
    Set sh = ActiveWorkbook.ActiveSheet.Shapes("Diagram 1")
    With sh
        .Select
        Set sa = .SmartArt
        sa.Reverse = msoTrue
    End With
End Sub

That is, 'left-to-right' is the 'reverse' property. See:

http://msdn.microsoft.com/en-us/library/office/microsoft.office.core.smartart.reverse%28v=office.15%29.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top