1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
Sub ListeBlocsConstruction()
Dim gall As BuildingBlockTypes
Dim cat As Category
Dim bb As BuildingBlock
Dim para As Paragraph
Dim mytable As Table
Dim i as integer, j as integer, v as integer
'Editer pour chaque type, et chaque catégorie Le nom du type, de la catégorie, le nom du bloc de construction et son
'Contenu non mis en forme séparé par un signe de tabulation, et un autre de paragraphe en fin de ligne, au point d'insertion du document actif
For i = 1 To Templates(l) .BuildingBlockTypes.Count
Set gall= Templates(l) .BuildingBlockTypes(i)
For j = 1 To gall.Categories.Count
Set cat = gall.Categories(j)
For v = 1 To cat.BuildingBlocks.Count
Set bb = cat.BuildingBlocks(v)
Selection.TypeText gall.Name & vbTab & cat.Name & vbTab
& bb.Name & vbTab & bb.Value & vbCr
Next v
Next j
Next i
'Certains blocs n'ont pas de signe de fin de paragraphe en fin de contenu,d'autres si.
'enlever les paragraphes vides
For Each para In ActiveDocument.Paragraphs
If para.Range.Text= vbCr Then
para.Range.Delete
End If
Next para
'Transformer le texte en tableau
Set mytable = ActiveDocument.Range.ConvertToTable(Separator:=vbTab)
'Trier la tableau par type, categorie et nom
mytable.Sort ExcludeHeader:=False, FieldNumber:="Colonne l",
SortFieldType:=wdSortFieldAlphanumeric, _
SortOrder:=wdSortOrderAscending, _
FieldNumber2:="Colonne 2", SortFieldType2:=wdSortFieldAlphanumeric,
SortOrder2:=wdSort0rderAscending, FieldNumber3:="Colonne 3",
SortFieldType3:=wdSortFieldAlphanumeric,
SortOrder3:=wdSortOrderAscending
'Ajouter une ligne de titre au tableau
With Selection
'deplacer la selection au début du tableau
.HomeKey Unit:=WdTable
'Inserer une ligne au-dessus
.InsertRowsAbove 1
'Ajouter le texte à la 1ère ligne du tableau
.Tables(1) .Cell(l, 1) .Range.Text = "Galerie"
.Tables(l) .Cell(l, 2) .Range.Text = "Catégorie"
.Tables(1) .Cell( 1, 3) .Range.Text = "Nom"
.Tables(l) .Cell(l, 4) .Range.Text = "Contenu"
'Mettre en gras la 1ère ligne
.Tables(l) .Rows(ll .Range.Bold = True
'Ajouter les colonnes au contenu
.Tables(l) .AutoFitBehavior (wdAutoFitContent)
End With
End Sub |
Partager