Deprecated: RegularLabs\Library\ArrayHelper::implode(): Implicitly marking parameter $last_glue as nullable is deprecated, the explicit nullable type must be used instead in /homepages/10/d550841420/htdocs/libraries/regularlabs/src/ArrayHelper.php on line 225
Comment mettre à jour tous les champs situés dans tous les en-têtes et pieds de page d'un document ?

Recherche

Voici une macro qui met à jour tous les champs qui se trouvent en en-tête et en pied de page dans toutes les sections d'un document.

Sub maj_champ()
Dim oField As Field
Dim oSection As Section
Dim oHeader As HeaderFooter
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
If oFooter.Exists Then
For Each oField In oFooter.Range.Fields
oField.Update
Next oField
End If
Next oFooter
For Each oHeader In oSection.Headers
If oHeader.Exists Then
For Each oField In oHeader.Range.Fields
oField.Update
Next oField
End If
Next oHeader
Next oSection
ActiveDocument.PrintPreview
ActiveDocument.ClosePrintPreview
End Sub

 

 


Voici une macro qui met à jour les champs des en-têtes de la première section d'un document :

 

Sub maj_champ2()
Dim oField As Field
Dim oHeader As HeaderFooter

For Each oHeader In ActiveDocument.Sections(1).Headers
If oHeader.Exists Then
For Each oField In oHeader.Range.Fields
oField.Update
Next oField
End If
Next oHeader
End Sub

 

Et pour la section en cours :

Sub maj_champ2()
Dim oField As Field
Dim oHeader As HeaderFooter

For Each oHeader In Selection.Sections(1).Headers
If oHeader.Exists Then
For Each oField In oHeader.Range.Fields
oField.Update
Next oField
End If
Next oHeader
End Sub

Statistiques

France 72,3% France
Canada 5,3% Canada
Chine 3,7% Chine

Total:

154

Pays
018457934
Aujourd'hui: 119
Hier: 236
Cette semaine: 119
Semaine dernière: 2.729
Ce mois: 5.862