none
Organization Chart RRS feed

  • Question

  • Hello, good morning. 

    I wonder if it is possible to mount an organization chart using macro in Word 2010. 

    I'm trying to do but I can not. You can only do this through Excel or Word also provides this tool? 

    If so, how should be the code? 

    I look back.
    Monday, June 3, 2013 2:40 PM

Answers

All replies

  • A starting point...

    Sub insertOrgChart()
    Dim saNode As office.SmartArtNode
    Dim i As Integer
    Dim ishp As Word.InlineShape '(or use a Shape object)
    Set ishp = ActiveDocument.InlineShapes.AddSmartArt(Application.SmartArtLayouts(97), Selection.Range)
    Set ishp = Nothing
    End Sub
    

    There's a list of layouts at

    http://blogs.msdn.com/b/officedevdocs/archive/2012/03/08/smartart-graphic-index-numbers-in-word-2010.aspx

    Beyond that, I think you'll need to consult the SmartArt object model reference, e.g. here:

    http://msdn.microsoft.com/en-us/library/office/ff870203(v=office.14).aspx 


    Peter Jamieson

    Monday, June 3, 2013 5:15 PM
  • Great,

    Could properly generate the SmartArt with the following code:

    Sub SmartArtSub()
    Dim myShape As Shape
    Dim mySmartArt As SmartArt
     
    Set myShape = ActiveDocument.Shapes.AddSmartArt(Application.SmartArtLayouts(97), 50, 50, 200, 200)
    Set mySmartArt = myShape.SmartArt
     
    mySmartArt.Color = Application.SmartArtColors(1)
    mySmartArt.QuickStyle = Application.SmartArtQuickStyles.Item(1)

    End Sub

    One last question, would you know if there is compatibility with Office 2007.

    Grateful for the return.

    Tuesday, June 4, 2013 1:37 PM
  • If you create this SmartArt type in Word 2010, save the .docx and open in Word 2007 it should work (i.e. it does here, with Office 2007 SP2). However, Office 2007 does not expose the SmartArt object model, so it does not seem to be possible to work with it on that version, except maybe to detect that your image has type "SmartArt"



    Peter Jamieson

    Tuesday, June 4, 2013 2:14 PM