ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating an organization diagram in Excel (https://www.excelbanter.com/excel-programming/355517-creating-organization-diagram-excel.html)

[email protected]

Creating an organization diagram in Excel
 
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"


NickHK

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"




[email protected]

Creating an organization diagram in Excel
 
For some reason, I don't have the macro recorder. The macro security is
set to Low !!
By the way the organizational chart is better than the flowchart.


NickHK

Creating an organization diagram in Excel
 
sedky,
If you cannot record a macro then how are you going to run any VBA code.
I assume this is a feature added after Excel 9, but I would imagine
something similar would apply.

NickHK

wrote in message
ups.com...
For some reason, I don't have the macro recorder. The macro security is
set to Low !!
By the way the organizational chart is better than the flowchart.




NickHK[_2_]

Creating an organization diagram in Excel
 
"this" refers to the organisational chart, not inability of running macros,
in case anyone was in doubt.

NickHK

"NickHK" wrote in message
...
sedky,
If you cannot record a macro then how are you going to run any VBA code.
I assume this is a feature added after Excel 9, but I would imagine
something similar would apply.

NickHK

wrote in message
ups.com...
For some reason, I don't have the macro recorder. The macro security is
set to Low !!
By the way the organizational chart is better than the flowchart.






[email protected]

Creating an organization diagram in Excel
 
I am able to run VBA code. I am running Excel 2003 by the way, but for
some reason "Record Macro" is not on the list. The code that I
originally pasted is fully functional (even the code you suggested),
but I wanted to get an idea of how to link up those organizational
chart boxes.



All times are GMT +1. The time now is 04:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com