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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
| Sub Charte()
'--------------------------------Recherche par blocs------------------------------------------"
With Selection.Find
.ClearFormatting
.Text = "Projet :"
.MatchCase = False
.Wrap = wdFindContinue
.Execute
If .Found Then
Flag_1 = True
Else: Flag_1 = False
End If
End With
'---------------- tester l'existance du bloc numéro 1 ----------------------------------------'
If Flag_1 = True Then
MsgBox "Le projte existe deja"
Else
MsgBox "inseretion du projet"
Selection.EndKey Unit:=wdStory
With Selection.Font
.Name = "Arial"
.Size = 12
.Bold = True
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
End With
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
MyRange.InsertAfter ("Projet :")
ActiveDocument.Paragraphs.Add
End If
With Selection.Find
.ClearFormatting
.Text = "Secteur d'activité :"
.MatchCase = False
.Wrap = wdFindContinue
.Execute
If .Found Then
Flag_2 = True
Else: Flag_2 = flase
End If
End With
'---------------- tester l'existance du bloc numéro 2 ----------------------------------------'
If Flag_2 = True Then
MsgBox "Le secteur existe deja"
ElseIf Flag_2 = False And Flag_1 = True Then
MsgBox "inseretion du secteur aprés le projet "
'ordre
Selection.EndKey Unit:=wdStory
With Selection.Font
.Name = "Arial"
.Size = 12
.Bold = True
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
End With
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
MyRange.InsertAfter ("Secteur d'activité :")
ActiveDocument.Paragraphs.Add
Else
MyRange.InsertAfter ("Secteur d'activité :")
ActiveDocument.Paragraphs.Add
End If
With Selection.Find
.ClearFormatting
.Text = "Numéro du projet :"
.MatchCase = False
.Wrap = wdFindContinue
.Execute
If .Found Then
Flag_3 = True
Else: Flag_3 = flase
End If
End With
'---------------- tester l'existance du bloc numéro 3 ----------------------------------------'
If Flag_3 = True Then
MsgBox "Le Numéro du projet existe deja"
Else
MsgBox "inseretion du Numéro du projet :"
Selection.EndKey Unit:=wdStory
With Selection.Font
.Name = "Arial"
.Size = 12
.Bold = True
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
End With
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
MyRange.InsertAfter ("Numéro du projet :")
ActiveDocument.Paragraphs.Add
End If
With Selection.Find
.ClearFormatting
.Text = "Tableaux des données 2013:"
.MatchCase = False
.Wrap = wdFindContinue
.Execute
If .Found Then
Flag_4 = True
Else: Flag_4 = flase
End If
End With
'---------------- tester l'existance du bloc numéro 4----------------------------------------'
If Flag_4 = True Then
MsgBox "L'Tableaux des données 2013 existe deja"
Else
MsgBox "inseretion du Tableaux des données 2013:"
Selection.EndKey Unit:=wdStory
With Selection.Font
.Name = "Arial"
.Size = 12
.Bold = True
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
End With
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
MyRange.InsertAfter ("Tableaux des données 2013:")
Application.Run ("Tableau_CG_1")
ActiveDocument.Paragraphs.Add
End If
With Selection.Find
.ClearFormatting
.Text = "Tableaux des données 2014 :"
.MatchCase = False
.Wrap = wdFindContinue
.Execute
If .Found Then
Flag_5 = True
Else: Flag_5 = flase
End If
End With
'---------------- tester l'existance du bloc numéro 5 ----------------------------------------'
If Flag_5 = True Then
MsgBox "Le Tableaux des données 2014 existe deja"
Else
MsgBox "inseretion du Tableaux des données 2014"
Selection.EndKey Unit:=wdStory
With Selection.Font
.Name = "Arial"
.Size = 12
.Bold = True
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
End With
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
MyRange.InsertAfter ("Tableaux des données 2014:")
With Selection.Font
.Name = "Arial"
.Size = 12
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
End With
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
Application.Run ("Tableau_CG_1")
ActiveDocument.Paragraphs.Add
End If
With Selection.Find
.ClearFormatting
.Text = "Mot Clé :"
.MatchCase = False
.Wrap = wdFindContinue
.Execute
If .Found Then
Flag_7 = True
Else: Flag_7 = flase
End If
End With
'---------------- tester l'existance du bloc numéro 7 ----------------------------------------'
If Flag_7 = True Then
MsgBox "L'Mot Clé existe deja"
Else
MsgBox "inseretion de Mot Clé :"
Selection.EndKey Unit:=wdStory
With Selection.Font
.Name = "Arial"
.Size = 12
.Bold = True
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
End With
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
MyRange.InsertAfter ("Mot Clé :")
ActiveDocument.Paragraphs.Add
End If
With Selection.Find
.ClearFormatting
.Text = "Historique des évolutions :"
.MatchCase = False
.Wrap = wdFindContinue
.Execute
If .Found Then
Flag_8 = True
Else: Flag_8 = flase
End If
End With
'---------------- tester l'existance du bloc numéro 8 ----------------------------------------'
If Flag_8 = True Then
On Error Resume Next
MsgBox "Historique des évolutions existe deja"
Else
MsgBox "inseretion de l'Historique des évolutions :"
Selection.EndKey Unit:=wdStory
With Selection.Font
.Name = "Arial"
.Size = 12
.Bold = True
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
End With
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
MyRange.InsertAfter ("Historique des évolutions :")
With Selection.Font
.Name = "Arial"
.Size = 12
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
End With
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
Application.Run ("Tableau_CG_2")
ActiveDocument.Paragraphs.Add
End If
With Selection.Find
.ClearFormatting
.Text = "Sommaire"
.MatchCase = False
.Wrap = wdFindContinue
.Execute
If .Found Then
Flag_1 = True And ordre = 1
Else: Flag_1 = False And ordre = 0
End If
End With
'---------------- tester l'existance du bloc numéro 9 ----------------------------------------'
If Flag_9 = True Then
On Error Resume Next
MsgBox ("Le sommaire n'existe pas")
Else
MsgBox "Inserertion du sommaire "
With Selection.Font
.Name = "Arial"
.Size = 12
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
End With
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
Application.Run ("Sommaire")
ActiveDocument.Paragraphs.Add
End If
End Sub
Sub Tableau_CG_1()
'
Dim oTbl As Table
Selection.EndKey Unit:=wdStory
Set oTbl = ActiveDocument.Tables.Add(Range:=Selection.Range, NumRows:=2, numcolumns:=3)
With Selection
oTbl.Cell(1, 1).Range.Text = "Numéro"
oTbl.Cell(1, 2).Range.Text = "Nom de document"
oTbl.Cell(1, 3).Range.Text = "Description du document"
End With
'Set oTbl = Nothing
With Selection.Tables(1)
If .Style <> "Grille du tableau" Then
.Style = "Grille du tableau"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
.ApplyStyleRowBands = True
.ApplyStyleColumnBands = False
.Cell(1, 1).Shading.Texture = wdTextureNone
.Cell(1, 1).Shading.ForegroundPatternColor = wdColorAutomatic
.Cell(1, 1).Shading.ForegroundPatternColor = -603923969
.Cell(1, 2).Shading.Texture = wdTextureNone
.Cell(1, 2).Shading.ForegroundPatternColor = wdColorAutomatic
.Cell(1, 2).Shading.ForegroundPatternColor = -603923969
.Cell(1, 3).Shading.Texture = wdTextureNone
.Cell(1, 3).Shading.ForegroundPatternColor = wdColorAutomatic
.Cell(1, 3).Shading.ForegroundPatternColor = -603923969
End With
'Pour éviter le problème de tableau dans un autre tableau
Selection.EndKey Unit:=wdStory
End Sub
Sub Tableau_CG_2()
Dim oTbl As Table
Selection.EndKey Unit:=wdStory
Set oTbl = ActiveDocument.Tables.Add(Range:=Selection.Range, NumRows:=2, numcolumns:=4)
With oTbl.Borders
oTbl.Cell(1, 1).Range.Text = "N°"
oTbl.Cell(1, 2).Range.Text = "Date"
oTbl.Cell(1, 3).Range.Text = " modification "
oTbl.Cell(1, 4).Range.Text = "données"
End With
Set oTbl = Nothing
' Pour éviter le problème
With Selection.Tables(1)
If .Style <> "Grille du tableau" Then
.Style = "Grille du tableau"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
.ApplyStyleRowBands = True
.ApplyStyleColumnBands = False
.Cell(1, 1).Shading.Texture = wdTextureNone
.Cell(1, 1).Shading.ForegroundPatternColor = wdColorAutomatic
.Cell(1, 1).Shading.ForegroundPatternColor = -603923969
.Cell(1, 2).Shading.Texture = wdTextureNone
.Cell(1, 2).Shading.ForegroundPatternColor = wdColorAutomatic
.Cell(1, 2).Shading.ForegroundPatternColor = -603923969
.Cell(1, 3).Shading.Texture = wdTextureNone
.Cell(1, 3).Shading.ForegroundPatternColor = wdColorAutomatic
.Cell(1, 3).Shading.ForegroundPatternColor = -603923969
.Cell(1, 4).Shading.Texture = wdTextureNone
.Cell(1, 4).Shading.ForegroundPatternColor = wdColorAutomatic
.Cell(1, 4).Shading.ForegroundPatternColor = -603923969
End With
'Pour éviter le problème de tableau dans un autre tableau
Selection.EndKey Unit:=wdStory
End Sub
Sub Sommaire()
With ActiveDocument
.TablesOfContents.Add Range:=Selection.Range, RightAlignPageNumbers:= _
True, UseHeadingStyles:=True, UpperHeadingLevel:=1, _
LowerHeadingLevel:=3, IncludePageNumbers:=True, AddedStyles:="", _
UseHyperlinks:=True, HidePageNumbersInWeb:=True, UseOutlineLevels:= _
True
.TablesOfContents(1).TabLeader = wdTabLeaderDots
.TablesOfContents.Format = wdIndexIndent
End With
End Sub |
Partager