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
|
Private Sub Changement_Wrd()
For Each MaSection In ActiveDocument.Sections
'Debug.Print ("######### SECTION " & MaSection.Index & " #########")
If (MaSection.PageSetup.Orientation = wdOrientPortrait) Then
'Debug.Print ("######### ORIENTATION: wdOrientPortrait = " & MaSection.PageSetup.Orientation)
PiedDePage_PosX = CentimetersToPoints(3.05)
PiedDePage_PosY = CentimetersToPoints(27.06)
Trigramme_PosX = CentimetersToPoints(11.11)
Trigramme_PosY = CentimetersToPoints(28)
ElseIf (MaSection.PageSetup.Orientation = wdOrientLandscape) Then
'Debug.Print ("######### ORIENTATION: wdOrientLandscape = " & MaSection.PageSetup.Orientation)
PiedDePage_PosX = CentimetersToPoints(7.38)
PiedDePage_PosY = CentimetersToPoints(18.32)
Trigramme_PosX = CentimetersToPoints(15.5)
Trigramme_PosY = CentimetersToPoints(19.14)
End If
For Each MonFooter In MaSection.Footers
If MonFooter.Exists Then
'Debug.Print ("######### FOOTER INDEX " & MonFooter.Index & " ######### IL Y A " & MonFooter.Range.ShapeRange.Count & " SHAPES")
' SELECTIONNE UNIQUEMENT LES SHAPES SE TROUVANT DANS LE PIED DE PAGE EN COUR:
' SI ON UTILISE PAS LE ShapeRange, ON AURA POUR CHAQUE FOOTER, LA TOTALITÉ DES SHAPES DANS LA TOTALITÉ DES FOOTER DE LA TOTALITÉ DES SECTIONS DU DOCUMENT..... toutes les shapes de tous les footer quoi.
For Each MaShape In MonFooter.Range.ShapeRange
'Debug.Print ("___________________________________________")
Debug.Print ("## MaShape.Name : " & MaShape.Name)
' SI LA SHAPE EN COURS CONTIENT BIEN UNE ZONE DE TEXTE:
If MaShape.TextFrame.HasText Then
MaShape.Select ' je pense pas que ce select est utile...
Debug.Print ("MaShape.Name : " & MaShape.Name)
Dim TypeDeShape As String
' DetectionType() est une fonction qui me renvoi un String "TRIGRAMME" OU "PIED_DE_PAGE_2ND" OU "PIED_DE_PAGE"
' dans cette fonction je test le contenu textuel de la shape en cour pour en determiner la nature (trigramme ou pied de page 1 ou 2)
TypeDeShape = DetectionType(MaShape)
'Debug.Print (" TypeDeShape : " & TypeDeShape)
'Debug.Print (" Contient le texte : " & MaShape.TextFrame.TextRange.Text)
' ###### DEFINITION APPARENCE DU TEXTE ####################################################
' Ici je défini l'apparence de mon texte (police, taille, couleur, alignement, espacement des lignes, etc)
MaShape.TextFrame.TextRange.Font.Size = FontSize
MaShape.TextFrame.TextRange.Font.Name = FontName
MaShape.TextFrame.TextRange.Font.ColorIndex = wdBlack
If TypeDeShape = "TRIGRAMME" Then
MaShape.TextFrame.TextRange.Paragraphs.Alignment = wdAlignParagraphRight
Else
MaShape.TextFrame.TextRange.Paragraphs.Alignment = wdAlignParagraphLeft
End If
MaShape.TextFrame.TextRange.Paragraphs.LineSpacingRule = wdLineSpaceAtLeast
MaShape.TextFrame.TextRange.Paragraphs.LineSpacing = 1
MaShape.TextFrame.TextRange.Paragraphs.SpaceAfter = False
MaShape.TextFrame.TextRange.Paragraphs.SpaceBefore = False
Debug.Print ("////////////////////////////////////")
Debug.Print (MaShape.Name)
Debug.Print (MaShape.Name)
MaShape.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
' ############################################################
' VBA ME MET UNE ERREUR A CE NIVEAU !!!!!!!!!!!
MaShape.RelativeVerticalPosition = wdRelativeVerticalPositionPage
' ############################################################
If TypeDeShape = "TRIGRAMME" Then
MaShape.Width = Trigramme_W
MaShape.Height = Trigramme_H
MaShape.Left = Trigramme_PosX
MaShape.Top = Trigramme_PosY
ElseIf ((TypeDeShape = "PIED_DE_PAGE_2ND") Or (TypeDeShape = "PIED_DE_PAGE")) Then
MaShape.Width = PiedDePage_W
MaShape.Height = PiedDePage_H
MaShape.Left = PiedDePage_PosX
MaShape.Top = PiedDePage_PosY
Else
End If
' ###### FIN DEFINITION APPARENCE DU TEXTE ####################################################
Select Case TypeDeShape
Case "TRIGRAMME"
'Debug.Print ("######### CHANGEMENT DU TRIGRAMME #########")
'Debug.Print ("######### NOM DE LA SHAPE : " & MaShape.Name)
' Config_Trigramme MaShape 'une fonction que j'avais fait pour dimensionner et positionner le Trigramme
MaShape.TextFrame.TextRange.Select
'Debug.Print ("TEXTE DU TRIGRAMMES A CHANGER : " & Selection.Text)
Selection.Font.Bold = True
If (pos_TRIGRAMME > 0) Then
'Debug.Print ("Renplacement de 'TRIGRAMME_MACRO' par : " & TrigrammeSociete)
Selection.Text = Replace(Selection.Text, "_TRIGRAMME_MACRO_", "_" & TrigrammeSociete & "_")
ElseIf (TrigrammeDansZDT <> "") Then
'Debug.Print ("Renplacement de " & TrigrammeDansZDT & " par : " & TrigrammeSociete)
Selection.Text = Replace(Selection.Text, "_" & TrigrammeDansZDT & "_", "_" & TrigrammeSociete & "_")
End If
Case "PIED_DE_PAGE_2ND"
'Debug.Print ("######### CHANGEMENT DU PIED DE PAGE 02 #########")
'Debug.Print ("######### NOM DE LA SHAPE " & MaShape.Name)
'Config_PDP MaShape 'une fonction que j'avais fait pour dimensionner et positionner le Pied de page 02
MaShape.TextFrame.TextRange.Select
'Debug.Print ("TEXTE A CHANGER : " & Selection.Text)
Selection.Font.Bold = True
Selection.TypeText Text:=RetourLigne & NomSociete
Selection.Font.Bold = False
Selection.TypeText Text:=" - Le gros slogan de la Société"
Case "PIED_DE_PAGE"
'Debug.Print ("######### CHANGEMENT DU PIED DE PAGE 01 #########")
'Config_PDP MaShape 'une fonction que j'avais fait pour dimensionner et positionner le Pied de page
MaShape.TextFrame.TextRange.Select
'Debug.Print ("TEXTE A CHANGER : " & Selection.Text)
Selection.Font.Bold = True
' RetourLigne = Chr(13)
Selection.TypeText Text:=RetourLigne & NomSociete & " "
Selection.Font.Bold = False
' Ligne1 à Ligne 5 sont des STRING
Selection.TypeText Text:=Ligne1 & Ligne2 & Ligne3 & Ligne4 & Ligne5
End Select
Else
Debug.Print ("## Script non applicable.")
End If
Next MaShape
End If
'Debug.Print (" ")
'Debug.Print (" ")
Next MonFooter
Next MaSection
' UNE FOIS LE SCRIPT TERMINÉ ON RETMET LE CURSEUR SUR LA PAGE AU DÉBUT DU DOCUMENT
Selection.EscapeKey
Selection.Collapse
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
'ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.EscapeKey
Selection.HomeKey Unit:=wdStory
End Sub |
Partager