Ces marques de format sont appelées "caractères non imprimables"... On ne peut donc pas les imprimer. L'astuce consiste donc à faire un recherche-remplace et de remplacer ces marques par l'équivalent (une image) imprimable :
- La marque de paragraphe ALT+244 ¶
- les parenthèses encadrant un champ par ALT+123 {, et ALT+125 }
- le trait d'union insécable par un trait d'union (manœuvre irréversible)
- le trait d'union conditionnel par ALT+170 ¬
- le saut de ligne manuel par ALT+168, police symbol
- la tabulation par ALT+169 ou 232 , police symbol
- l'espace insécable par ALT+248 °
Les codes sont les codes à entrer dans la boîte REMPLACER.
Et voici une macro qui traite le problème plus rapidement :
Sub ImprimerMarques()
'macro écrite par Geo, mise à jour par m@rina
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = "¶^p"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^t"
.Replacement.Text = ChrW(8594) & "^t"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^l"
.Replacement.Text = ChrW(8629) & "^l"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
Application.PrintOut FileName:="", _
Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", _
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False
With Selection.Find
.Text = "¶^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = ChrW(8594) & "^t"
.Replacement.Text = "^t"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = ChrW(8629) & "^l"
.Replacement.Text = "^l"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = "¶^p"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^t"
.Replacement.Text = ChrW(8594) & "^t"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^l"
.Replacement.Text = ChrW(8629) & "^l"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
Application.PrintOut FileName:="", _
Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", _
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False
With Selection.Find
.Text = "¶^p"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = ChrW(8594) & "^t"
.Replacement.Text = "^t"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = ChrW(8629) & "^l"
.Replacement.Text = "^l"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub