Salut,
Le premier problème est que tu n'adresses pas une colonne.
Selection.Columns(2).PreferredWidth = CentimetersToPoints(2)
tu reçois un message stipulant que le menbre de la collection n'existe pas.
ActiveDocument.Tables(1).Columns(2).PreferredWidth = CentimetersToPoints(2)
Dans ce morceau de code, tu commence par adresser une table pour ensuite travailler avec une sélection.
1 2 3
| With ActiveDocument.Tables(1)
Selection.Columns(1).PreferredWidth = CentimetersToPoints(1)
End With |
Ton code devrait ressembler à ça :
1 2 3
| With ActiveDocument.Tables(1)
.Columns(1).PreferredWidth = CentimetersToPoints(1)
End With |
En Fait, With introduit une possibilité d'utiliser plusieurs méthodes ou propriétés pour un même objet.
1 2 3 4 5 6
| With monobjet
.propriété1
.propriété2
.Methode1
.methode2
End With |
Et est identique à :
1 2 3 4 5
|
monobjet.propriété1
monobjet.propriété2
monobjet.Methode1
monobjet.methode2 |
donc ton code devrait devenir :
1 2 3 4 5
|
With ActiveDocument.Tables(1)
.Columns(1).PreferredWidth = CentimetersToPoints(1)
.Columns(2).PreferredWidth = CentimetersToPoints(2)
End With |
Partager