Bonjour,
Je cherche à imprimer une zone qui part de A1 à la dernière cellule occupée de la colonne N et ce de la feuille de calculs "1" à la feuille "14".
J'ai un problème avec la définition de ma zone d'impression, je pars du code:
Et compte faire une boucle sur la feuille (i = 1 to i = 14 ....)
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
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 Sub PRINTSEL() ' ' PRINTSEL Macro ' ' Sheets("1").Range(Cells(1, 1), Cells(Cells(Cells.Rows.Count, 1).End(xlUp).Row, 14)).Select Application.PrintCommunication = False With ActiveSheet.PageSetup .PrintTitleRows = "" .PrintTitleColumns = "" End With Application.PrintCommunication = True ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), Cells(Cells(Cells.Rows.Count, 1).End(xlUp).Row, 14)).Select Application.PrintCommunication = False With ActiveSheet.PageSetup .LeftHeader = "" .CenterHeader = "" .RightHeader = "" .LeftFooter = "" .CenterFooter = "&Z&F" .RightFooter = "Page &P" .LeftMargin = Application.InchesToPoints(0.196850393700787) .RightMargin = Application.InchesToPoints(0.196850393700787) .TopMargin = Application.InchesToPoints(0.275590551181102) .BottomMargin = Application.InchesToPoints(0.29) .HeaderMargin = Application.InchesToPoints(0.15748031496063) .FooterMargin = Application.InchesToPoints(0.15748031496063) .PrintHeadings = False .PrintGridlines = False .PrintComments = xlPrintNoComments .CenterHorizontally = False .CenterVertically = False .Orientation = xlPortrait .Draft = False .PaperSize = xlPaperA4 .FirstPageNumber = xlAutomatic .Order = xlDownThenOver .BlackAndWhite = False .Zoom = False .FitToPagesWide = 1 .FitToPagesTall = 1 .PrintErrors = xlPrintErrorsDisplayed .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .ScaleWithDocHeaderFooter = True .AlignMarginsHeaderFooter = True .EvenPage.LeftHeader.Text = "" .EvenPage.CenterHeader.Text = "" .EvenPage.RightHeader.Text = "" .EvenPage.LeftFooter.Text = "" .EvenPage.CenterFooter.Text = "" .EvenPage.RightFooter.Text = "" .FirstPage.LeftHeader.Text = "" .FirstPage.CenterHeader.Text = "" .FirstPage.RightHeader.Text = "" .FirstPage.LeftFooter.Text = "" .FirstPage.CenterFooter.Text = "" .FirstPage.RightFooter.Text = "" End With Application.PrintCommunication = True Selection.PrintOut Copies:=1, Collate:=True End Sub
Quand je lance ce premier code, excel plante en me renvoyant erreur définie par l'application ou par l'objet.
Erreur que j'ai du mal à trouver.
Si quelqu'un voit quelque chose, merci beaucoup
J'ai corrigé comme suit:
L'erreur, cette fois ci est:
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
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 Sub PRINTSEL() ' ' PRINTSEL Macro ' ' Worksheets("1").Activate Range(Cells(1, 1), Cells(Cells(Cells.Rows.Count, 1).End(xlUp).Row, 14)).Select Application.PrintCommunication = False With ActiveSheet.PageSetup .PrintTitleRows = "" .PrintTitleColumns = "" End With Application.PrintCommunication = True ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), Cells(Cells(Cells.Rows.Count, 1).End(xlUp).Row, 14)).Select Application.PrintCommunication = False With ActiveSheet.PageSetup .LeftHeader = "" .CenterHeader = "" .RightHeader = "" .LeftFooter = "" .CenterFooter = "&Z&F" .RightFooter = "Page &P" .LeftMargin = Application.InchesToPoints(0.196850393700787) .RightMargin = Application.InchesToPoints(0.196850393700787) .TopMargin = Application.InchesToPoints(0.275590551181102) .BottomMargin = Application.InchesToPoints(0.29) .HeaderMargin = Application.InchesToPoints(0.15748031496063) .FooterMargin = Application.InchesToPoints(0.15748031496063) .PrintHeadings = False .PrintGridlines = False .PrintComments = xlPrintNoComments .CenterHorizontally = False .CenterVertically = False .Orientation = xlPortrait .Draft = False .PaperSize = xlPaperA4 .FirstPageNumber = xlAutomatic .Order = xlDownThenOver .BlackAndWhite = False .Zoom = False .FitToPagesWide = 1 .FitToPagesTall = 1 .PrintErrors = xlPrintErrorsDisplayed .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .ScaleWithDocHeaderFooter = True .AlignMarginsHeaderFooter = True .EvenPage.LeftHeader.Text = "" .EvenPage.CenterHeader.Text = "" .EvenPage.RightHeader.Text = "" .EvenPage.LeftFooter.Text = "" .EvenPage.CenterFooter.Text = "" .EvenPage.RightFooter.Text = "" .FirstPage.LeftHeader.Text = "" .FirstPage.CenterHeader.Text = "" .FirstPage.RightHeader.Text = "" .FirstPage.LeftFooter.Text = "" .FirstPage.CenterFooter.Text = "" .FirstPage.RightFooter.Text = "" End With Application.PrintCommunication = True Selection.PrintOut Copies:=1, Collate:=True End Sub
Impossible de définir la propriété de PrintArea de la classe PageSetup
Corrigé en:
Erreur: La méthode Range de l'objet global a échoué
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
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 Sub PRINTSEL() ' ' PRINTSEL Macro ' ' Worksheets("1").Activate Range(Cells(1, 1), Cells(Cells(Cells.Rows.Count, 1).End(xlUp).Row, 14)).Select Application.PrintCommunication = False With ActiveSheet.PageSetup .PrintTitleRows = "" .PrintTitleColumns = "" End With Application.PrintCommunication = True ActiveSheet.PageSetup.PrintArea = "$A$1:" & Range(Cells(Cells(Cells.Rows.Count, 1).End(xlUp).Row, 14)) & "" Application.PrintCommunication = False With ActiveSheet.PageSetup .LeftHeader = "" .CenterHeader = "" .RightHeader = "" .LeftFooter = "" .CenterFooter = "&Z&F" .RightFooter = "Page &P" .LeftMargin = Application.InchesToPoints(0.196850393700787) .RightMargin = Application.InchesToPoints(0.196850393700787) .TopMargin = Application.InchesToPoints(0.275590551181102) .BottomMargin = Application.InchesToPoints(0.29) .HeaderMargin = Application.InchesToPoints(0.15748031496063) .FooterMargin = Application.InchesToPoints(0.15748031496063) .PrintHeadings = False .PrintGridlines = False .PrintComments = xlPrintNoComments .CenterHorizontally = False .CenterVertically = False .Orientation = xlPortrait .Draft = False .PaperSize = xlPaperA4 .FirstPageNumber = xlAutomatic .Order = xlDownThenOver .BlackAndWhite = False .Zoom = False .FitToPagesWide = 1 .FitToPagesTall = 1 .PrintErrors = xlPrintErrorsDisplayed .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .ScaleWithDocHeaderFooter = True .AlignMarginsHeaderFooter = True .EvenPage.LeftHeader.Text = "" .EvenPage.CenterHeader.Text = "" .EvenPage.RightHeader.Text = "" .EvenPage.LeftFooter.Text = "" .EvenPage.CenterFooter.Text = "" .EvenPage.RightFooter.Text = "" .FirstPage.LeftHeader.Text = "" .FirstPage.CenterHeader.Text = "" .FirstPage.RightHeader.Text = "" .FirstPage.LeftFooter.Text = "" .FirstPage.CenterFooter.Text = "" .FirstPage.RightFooter.Text = "" End With Application.PrintCommunication = True Selection.PrintOut Copies:=1, Collate:=True End Sub
Partager