Bonjour,
Dans le cadre de mon travail, on m'a demandé de créer une macro sur Word 2007 permettant d'insérer un pied-de-page. Celui-ci est sous forme de tableau avec des images et du texte à l’intérieur.
N'ayant jamais fais de macro, j'ai pu trouver quelques bouts de code par-ci par-là pour réussir à créer ce tableau. Cependant, l'action crée le tableau dans la page et non pas dans le pied-de-page.
Voici le code que j'ai mis dans la macro (Il est sans doute pas du tout propre et contient sûrement des bouts inutiles, mais comme dis précédemment, c'est la première fois que j'en fais et j'ai dû piocher un peu partout sur le web) :
J'aimerais donc, que cette action ne se réalise non pas sur la page, mais dans le pied-de-page. Connaissez-vous un moyen de faire ça ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162 Sub Bas_de_page() ' ' Bas_de_page Macro ' ' Dim WordApp As Word.Application Dim WordDoc As Word.Document Set myRange = ActiveDocument.Range(0, 0) ActiveDocument.Tables.Add Range:=myRange, NumRows:=1, NumColumns:=5 'insérer une image dans la 3eme Cellule de la 2eme colonne (dans le 1er tableau d'un document Word ) myRange.Tables(1).Columns(1).Cells(1).Range.InlineShapes.AddPicture _ FileName:="H:\Modèles\Logos\Zewo.png", linkToFile:=False, saveWithDocument:=True With ActiveDocument.InlineShapes(ActiveDocument.InlineShapes.Count) .Height = 30 'redimensionne hauteur image .Width = 30 'redimensionne largeur image End With 'insérer une image dans la 3eme Cellule de la 2eme colonne (dans le 1er tableau d'un document Word ) myRange.Tables(1).Columns(2).Cells(1).Range.InlineShapes.AddPicture _ FileName:="H:\Modèles\Logos\Eduqua.png", linkToFile:=False, saveWithDocument:=True With ActiveDocument.InlineShapes(ActiveDocument.InlineShapes.Count) .Height = 23 'redimensionne hauteur image .Width = 75 'redimensionne largeur image .PictureFormat.ColorType = msoPictureGrayscale End With With Selection.Tables(1) If .Style <> "Grille du tableau" Then .Style = "Grille du tableau" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = True .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = True End With 'Insertion des textes de la colone 2 Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.Font.Size = 8 Selection.Font.Name = "Arial" Selection.Font.Bold = True Selection.TypeText Text:="Site de la Chaux-de-Fonds" Selection.Font.Bold = False Selection.ParagraphFormat.Alignment = wdAlignParagraphRight Selection.TypeParagraph Selection.Font.Size = 8 Selection.Font.Bold = False Selection.TypeText Text:="Rue de la Paix 71 / cp 299" Selection.TypeParagraph Selection.ParagraphFormat.Alignment = wdAlignParagraphRight Selection.Font.Size = 8 Selection.Font.Bold = False Selection.TypeText Text:="2300 La Chaux-de-Fonds" Selection.TypeParagraph Selection.ParagraphFormat.Alignment = wdAlignParagraphRight Selection.Font.Size = 8 Selection.Font.Bold = False Selection.TypeText Text:="Téléphone 032 886 88 60" Selection.TypeParagraph Selection.ParagraphFormat.Alignment = wdAlignParagraphRight Selection.Font.Size = 8 Selection.Font.Bold = False Selection.TypeText Text:="Téléfax 032 886 82 40" Selection.ParagraphFormat.Alignment = wdAlignParagraphRight 'Insertion des textes de la colonne 3 Selection.MoveRight Unit:=wdCell Selection.Font.Size = 8 Selection.Font.Name = "Arial" Selection.Font.Bold = True Selection.TypeText Text:="Site de Neuchâtel" Selection.ParagraphFormat.Alignment = wdAlignParagraphRight Selection.TypeParagraph Selection.Font.Size = 8 Selection.Font.Bold = False Selection.TypeText Text:="Avenue du Premier-Mars 2a" Selection.TypeParagraph Selection.ParagraphFormat.Alignment = wdAlignParagraphRight Selection.Font.Size = 8 Selection.Font.Bold = False Selection.TypeText Text:="2000 Neuchâtel" Selection.TypeParagraph Selection.ParagraphFormat.Alignment = wdAlignParagraphRight Selection.Font.Size = 8 Selection.Font.Bold = False Selection.TypeText Text:="Téléphone 032 886 88 60" Selection.TypeParagraph Selection.ParagraphFormat.Alignment = wdAlignParagraphRight Selection.Font.Size = 8 Selection.Font.Bold = False Selection.TypeText Text:="Téléfax 032 886 82 67" Selection.ParagraphFormat.Alignment = wdAlignParagraphRight 'Insertion des textes de la colone 4 Selection.MoveRight Unit:=wdCell Selection.Font.Size = 8 Selection.Font.Name = "Arial" Selection.Font.Bold = True Selection.TypeText Text:="Croix-Rouge suisse" Selection.Font.Bold = False Selection.ParagraphFormat.Alignment = wdAlignParagraphRight Selection.TypeParagraph Selection.Font.Size = 8 Selection.Font.Bold = True Selection.TypeText Text:="Canton de Neuchâtel" Selection.TypeParagraph Selection.ParagraphFormat.Alignment = wdAlignParagraphRight Selection.Font.Size = 8 Selection.Font.Bold = False Selection.TypeText Text:="contact@croix-rouge-ne.ch" Selection.TypeParagraph Selection.ParagraphFormat.Alignment = wdAlignParagraphRight Selection.Font.Size = 8 Selection.Font.Bold = False Selection.TypeText Text:="www.croix-rouge-ne.ch" Selection.TypeParagraph Selection.ParagraphFormat.Alignment = wdAlignParagraphRight Selection.Font.Size = 8 Selection.Font.Bold = False Selection.TypeText Text:="CCP 20-1504-8" Selection.ParagraphFormat.Alignment = wdAlignParagraphRight 'Ajustement de la taille du tableau en fonction de son contenu ActiveDocument.Tables(1).AutoFitBehavior _ wdAutoFitContent 'Retrait de certaine bordures With Selection.Tables(1) .Borders(wdBorderTop).LineStyle = wdLineStyleNone .Borders(wdBorderBottom).LineStyle = wdLineStyleNone .Borders(wdBorderLeft).LineStyle = wdLineStyleNone End With Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.MoveLeft Unit:=wdCell Selection.Borders(wdBorderRight).LineStyle = wdLineStyleNone 'supprime la ligne de droite End Sub
Peut-être avec "ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter" ? J'avoue être un peu perdu et pourtant j'ai essayé plus d'une fois...
Je ne sais pas si mes explications sont claires, cependant je suis à disposition au cas où j'aurais oublié des détails importants.
Je vous remercie infiniement d'avance !
Kynoq
Partager