Bonjour,
je voulais savoir comment changer à partir d'une macro VBA la configuration de l'imprimante. Notamment pour changer les marges horizontales et verticales.
Merci pour votre aide!
Bonjour,
je voulais savoir comment changer à partir d'une macro VBA la configuration de l'imprimante. Notamment pour changer les marges horizontales et verticales.
Merci pour votre aide!
fait l'enregistrement de l'envoies d'un copie à l'imprimante (tu peut configurer les marges les entête le zoom ...)
l'enregistreur de macro va te donner un flot de paramètres (il est très disert)
tu auras un truc du genre
enfin des choses et des trucs en anglais qui sont avec des valeurs ce sont sur ces valeurs qu'il te faudra intervenir
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 With ActiveSheet.PageSetup .PrintTitleRows = "" .PrintTitleColumns = "" End With ActiveSheet.PageSetup.PrintArea = "$A$228:$F$266" With ActiveSheet.PageSetup .LeftHeader = "" .CenterHeader = "" .RightHeader = "" .LeftFooter = "" .CenterFooter = "" .RightFooter = "" .LeftMargin = Application.InchesToPoints(0.590551181102362) .RightMargin = Application.InchesToPoints(0.590551181102362) .TopMargin = Application.InchesToPoints(0.78740157480315) .BottomMargin = Application.InchesToPoints(0.78740157480315) .HeaderMargin = Application.InchesToPoints(0.708661417322835) .FooterMargin = Application.InchesToPoints(0.31496062992126) .PrintHeadings = False .PrintGridlines = True .PrintComments = xlPrintNoComments .PrintQuality = 300 .CenterHorizontally = True .CenterVertically = True .Orientation = xlPortrait .Draft = False .PaperSize = xlPaperA4 .FirstPageNumber = xlAutomatic .Order = xlDownThenOver .BlackAndWhite = False .Zoom = 100 .PrintErrors = xlPrintErrorsDisplayed End With
Quand je le disais disert
Le mieux est d'enregister la macro en faisant. Tu ne conserves que ces 6 lignes (+ les deux si marges en-têtes modifiées :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 With ActiveSheet.PageSetup .LeftMargin = Application.InchesToPoints(1.18110236220472) .RightMargin = Application.InchesToPoints(1.18110236220472) .TopMargin = Application.InchesToPoints(0.984251968503937) .BottomMargin = Application.InchesToPoints(0.984251968503937) 'si marges d'en-tête modifiées... '.HeaderMargin = Application.InchesToPoints(0.511811023622047) '.FooterMargin = Application.InchesToPoints(0.511811023622047) End with
Merci! Je vais essayer ça tout de suite!
Partager