View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Creating an organization diagram in Excel

sedky,
Record a macro creating 2 shapes and placing a connctor between them, from
the options on the Drawing toolbar. You'll get code that looks like:

ActiveSheet.Shapes.AddShape(msoShapeFlowchartProce ss, 97.5, 171#, 127.5,
48.75).Select
ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrepa ration, 327.75, 95.25,
197.25, 54#).Select
ActiveSheet.Shapes.AddConnector(msoConnectorStraig ht, 225#, 148.5, 110.25,
47.25).Select
Selection.ShapeRange.ConnectorFormat.BeginConnect
ActiveSheet.Shapes("AutoShape 1"), 4
Selection.ShapeRange.ConnectorFormat.EndConnect
ActiveSheet.Shapes("AutoShape 2"), 2

NickHK

wrote in message
oups.com...
Hi,

I am trying to create an organization chart programmatically in excel.
I got this code from a previous posting, but adding text doesn't work.
I also need to link the boxes together. Can someone please post some
code on how to do that?

Thanks

Dim shDiagram as Shape
Dim nodRoot As DiagramNode
Set shDiagram = ActiveSheet.Shapes.AddDiagram( _
Type:=msoDiagramOrgChart, Top:=10, _
Left:=15, Width:=400, Height:=475)
Set nodRoot = shDiagram.DiagramNode.Children.AddNode
nodRoot.TextShape.TextFrame.Characters.Text = "First Node"