converting Org chart child nodes from vertical into horizontal

M

Memo

Dear all
I'm working in generating and organization chart from database and
everything is worked very well but the result that I get keep draw the child
nodes in vertical rather than horizontal. and I need to presant the child
nodes in horizontal way to minimize the page width size.
i have been used the following code to do it, do i need to change somthing
on it or do i have another way to code it.
i'm using microsoft visio 2003 and i code it by VB.Net and i'm exporting the
result into HTML page

______________________________________________________________

Dim objVisio As Visio.Application

Dim objAddOn As Visio.Addon

Dim pagObj As Visio.Page

Dim shpObj As Visio.Shape

Dim celObjHeight As Visio.Cell

Dim celObjWidth As Visio.Cell

Dim vsoSaveAsWeb As VisSaveAsWeb

Dim vsoWebSettings As VisWebPageSettings

Dim strCommand As String

Dim i As Integer



strCommand = "/DATASOURCE= (your ODBC datasource name) ,TABLE=" _

& " (your table name) , DBQUALIFIER= (your database name)" _

& " /NAME-FIELD= (enter the name field)" _

& " /UNIQUEID-FIELD= (the master field)" _

& " /MANAGER-FIELD= (the reporting to field)" _

& " /DISPLAY-FIELDS= (enter the master fields (field1, field2,field 3,..))" _

& " /CUSTOM-PROPERTY-FIELDS= ( enter the custom fields (field1, field2,field
3,..)" _

& " /SHAPE-FIELD=MASTER_SHAPE"



‘create the visio chart in silent mode

objVisio = New Visio.InvisibleApp

‘generate the organization chart wizard

objAddOn = objVisio.Addons.ItemU("OrgCWiz")



'Run the add-on (errors are handled by the add-on)

On Error Resume Next



'Break up the string

Dim strCommandPart As String

Dim strCommandLeft As String

strCommandLeft = strCommand

objAddOn.Run("/S-INIT")

While (Len(strCommandLeft) > 0)

strCommandPart = Microsoft.VisualBasic.Left(strCommandLeft,
MAX_ARGSTRING_LENGTH)

strCommandLeft = Mid(strCommandLeft, Len(strCommandPart) + 1)

objAddOn.Run("/S-ARGSTR " + strCommandPart)

End While

objAddOn.Run("/S-RUN " + strCommandLeft)



vsoSaveAsWeb = objVisio.Application.SaveAsWebObject

' Get a VisWebPageSettings object.

vsoWebSettings = vsoSaveAsWeb.WebPageSettings

' Configure preferences.

With vsoWebSettings

..StartPage = 1

.EndPage = 2

.QuietMode = True

.TargetPath = "(set the uotput path) : C:\result.htm"

.SilentMode = True

End With



pagObj = objVisio.ActivePage



‘ resize the shaps to fit with it text

For i = 0 To pagObj.Shapes.Count

If pagObj.Shapes.Item(i).Name.Contains("Executive") Or
pagObj.Shapes.Item(i).Name.Contains("Manager") Or
pagObj.Shapes.Item(i).Name.Contains("Position") Then

pagObj.Shapes.Item(i).CellsSRC(1, 1, 1).FormulaForceU = "9.15625 in"

pagObj.Shapes.Item(i).CellsSRC(1, 1, 3).FormulaForceU = "1.6875 in"

End If

Next i



'redrow the organization chart



Dim placeStyleCell As Microsoft.Office.Interop.Visio.Cell

Dim routeStyleCell As Microsoft.Office.Interop.Visio.Cell



' Automatically layout the shapes.

placeStyleCell = pagObj.PageSheet.CellsSRC( _

CShort(Microsoft.Office.Interop.Visio.VisSectionIndices. _

visSectionObject), _

CShort(Microsoft.Office.Interop.Visio.VisRowIndices. _

visRowPageLayout), _

CShort(Microsoft.Office.Interop.Visio.VisCellIndices. _

visPLOPlaceDepth))



routeStyleCell = pagObj.PageSheet.CellsSRC( _

CShort(Microsoft.Office.Interop.Visio.VisSectionIndices. _

visSectionObject), _

CShort(Microsoft.Office.Interop.Visio.VisRowIndices. _

visRowPageLayout), _

CShort(Microsoft.Office.Interop.Visio.VisCellIndices. _

visPLORouteStyle))



placeStyleCell.Result(Microsoft.Office.Interop.Visio. _

VisUnitCodes.visPageUnits) = _


CDbl(Microsoft.Office.Interop.Visio.VisCellVals.visPLOPlaceTopToBottom)



routeStyleCell.Result(Microsoft.Office.Interop.Visio. _

VisUnitCodes.visPageUnits) = _

CDbl(Microsoft.Office.Interop.Visio.VisCellVals. _

visLORouteOrgChartWE)



pagObj.Layout()



pagObj.CenterDrawing()



‘generate the chart

vsoSaveAsWeb.CreatePages()

‘save it as a web

objVisio.ActiveDocument.Saved = True

objVisio.ActiveDocument.Close()

objAddOn = Nothing

objVisio.Quit()

objVisio = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top