Espacement d'organigramme Visio par programmation

I

IceBock

Bonjour, je travaille sur un projet pour créer des organigrammes Visio à
partir d'une base de données et d'une interface MS Access. Nous utilisons
Visio 2002 Standard et Ms Access XP.

Je ne parviens pas à utiliser des commandes vba pour utiliser la fonction
[organigramme - Modifier l'espacement]. La seule façon fonctionnelle que
j'ai trouvée d'utiliser ces fonctions est avec "sendkey" mais le résultat est
médiocre et instable.

J'ai essayé une alternative vba avec ce bout de code:

Public Sub set_espacement(ByRef pagObj As Object, ByRef shpObj As Object)

For Each pagObj In docObj.pages
Set shpsObj = pagObj.Shapes
For Each shpObj In pagObj.Shapes
If Not (shpObj.NameU Like "*Dynamic*") Then
shpObj.Cells("util.AL_cyBtwnSubs").Formula = "6 mm" 'Vertical
separation between standard subordinates
shpObj.Cells("util.AL_cyBelowParent").Formula = "6 mm" 'Vertical
separation below parent and above top-most standard subordinates
shpObj.Cells("util.AL_cxBtwnSubs").Formula = "6 mm" 'Horizontal
separation between standard subordinates
shpObj.Cells("util.AL_cxBtwnAssts").Formula = "6 mm" 'Horizontal
separation between assistants
End If
Next
Next

End Sub
'-------------------------------------------------------------------
Aucun erreur ne survient en faisant cela, les propriétés de formes sont
ajustées, mais l'espacement de l'organigramme ne change pas et lorsque je
vais dans la boite de dialogue [organigramme - Modifier l'espacement]
manuellement, les valeurs que j'ai envoyées sont absentes et non prisent en
compte.

Quelle serait donc la meilleure façon d'ajuster l'espacement de mon
organigramme ???
Toute aide sera apprécié.
 
C

Chris [Visio MVP]

Vous faites ceci de la manière correcte. Une suggestion pour placer les
valeurs dans la page : obtenez l'objet de PageSheet de l'objet de page. Par
exemple:

For each doc in Visio.Documents
For each pg in doc.Pages
set shpPage = pg.PageSheet
...
shpPage.CellsU("AvenueSizeX").Result("mm") = 6
'CellsU est un nom universel (en anglais) -- et fonctionnera dans
n'importe quelle langue-version de Visio.
...
Next
Next
 
I

IceBock

I work with the organization chart wizard that generate all the basic shapes.
Then i customise each shapes in visual basic with a loop.

When I set the values in visual basic with theese methods
- shpObj.Cells("util.AL_cyBtwnSubs").Formula = "6 mm"
- shpObj.Cells("util.AL_cyBelowParent").Formula = "6 mm"
- shpObj.Cells("util.AL_cxBtwnSubs").Formula = "6 mm"
- shpObj.Cells("util.AL_cxBtwnAssts").Formula = "6 mm"
- shpPage.CellsU("AvenueSizeX").Result("mm") = 6
- shpPage.CellsU("AvenueSizeY").Result("mm") = 6
- shpPage.Cells("TraitVersNoeudY").Formula = "3 mm"
- shpPage.Cells("TraitVersNoeudX").Formula = "3 mm"

All property are set the proper way and if I look at shape sheet in visio, I
see than the property have been corectly setted.

The problem are than the space between my shapes are not ajusted after I set
the property. Even if i use pagObj.layout command. That not give the same
result as if I adjust the spacing with the menu ( organization chart - change
spacing) .

Actually, the only working way I founded to adjust the space between my
shapes are with the menu and sendkey.

Example of the non working way:

After I create a chart, the default space between shapes is :
- shpPage.Cells("TraitVersNoeudY").Formula = "1 mm"

If I go in menu organization chart - change spacing and I use "looser", I
get :
- shpPage.Cells("TraitVersNoeudY").Formula = "2 mm"

But if I set that property to "5 mm", then I use looser function, the value
come to 1 mm greater than the previous value. My "5mm" is not taken in the
value change ???

So I think my value are not setted properly ? Is it a Bug in Visio ??
What did i do the wrong way ???
I'am not currently use the service pack 2, should I patch my installation of
visio ?

PS, I use a french version of Visio.

Any help welcome, in french or in english.
 
J

JuneTheSecond

These cells name are in French version?
Would anyone kindly translate them in Englich version?
"util.AL_cyBtwnSubs" = ???
"util.AL_cyBelowParent" = ???
..........
...........

"TraitVersNoeudY" = ???
"TraitVersNoeudX" = ???

I could not found these named cells, except "AvenueSizeX" and "AvenueSizeY".
 
C

Chris [Visio MVP]

You might have to call Page.Layout again. Changing the values does not cause
an immediate update of the drawing, and the space between shapes.
 

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