Microsoft 365 RESOLU Problème vue sur page après Impréssion

Bambi35

XLDnaute Occasionnel
Bonjours à tous

j'ai un problème avec mon fichier après avoir fermé l'apercu avant impression.
Dans mon fichier j'ai la page "Entree" ou je peux lancer 2 Formulaires.
Quand je lance le formulaire "Note de sortie" je peux lancer un PDF
et quand je ferme l'aperçu avant impression je reviens sur la page "Entree" A1:B7
Depuis J'ai modifier le code pour intégrer la mise en page mais depuis quand je ferme l'aperçu
avant impression je reviens sur la page "Entrée" mais la vue sur la page est décalée en (A10:H29).
Je ne trouve pas pourquoi ce changement.
Merci de votre aide

voici le code pour voir quand le PDF

Private Sub PDF_Click()
'Me.PrintForm -pour - apreçu
Me.Hide
Range("A1:A40").Select
Range("A40").Activate
ActiveSheet.PageSetup.PrintArea = "$A$1:$A$40"
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = "$A$1:$A$40"
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = _
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.393700787401575)
.RightMargin = Application.InchesToPoints(0.393700787401575)
.TopMargin = Application.InchesToPoints(0.393700787401575)
.BottomMargin = Application.InchesToPoints(0.15748031496063)
.HeaderMargin = Application.InchesToPoints(0.31496062992126)
.FooterMargin = Application.InchesToPoints(0.31496062992126)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.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
Sheets("PDF").Visible = True
'Aperçu avant impression de la Feuil1
Sheets("PDF").PrintPreview
Sheets("PDF").Visible = True
'Sheets("Fiche").Visible = Sheets("Formulaire").Range("c17") = ""
Sheets("PDF").Visible = True
Me.Show

End Sub

Merci de votre aide
B@mbi35
 

Pièces jointes

  • Demande de Sortie1.xlsm
    104 KB · Affichages: 12

Staple1600

XLDnaute Barbatruc
Bonjour le fil

•>Bambi35
Tu peux utiliser les balises [CODE=vb]texte macro[/CODE]
Cela donne cet affichage
VB:
Private Sub PDF_Click()
'Me.PrintForm -pour - apreçu
Me.Hide
Range("A1:A40").Select
Range("A40").Activate
ActiveSheet.PageSetup.PrintArea = "$A$1:$A$40"
Application.PrintCommunication = False
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = "$A$1:$A$40"
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0.393700787401575)
.RightMargin = Application.InchesToPoints(0.393700787401575)
.TopMargin = Application.InchesToPoints(0.393700787401575)
.BottomMargin = Application.InchesToPoints(0.15748031496063)
.HeaderMargin = Application.InchesToPoints(0.31496062992126)
.FooterMargin = Application.InchesToPoints(0.31496062992126)
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.Orientation = xlPortrait
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
End With
Application.PrintCommunication = True
Sheets("PDF").Visible = True
'Aperçu avant impression de la Feuil1
Sheets("PDF").PrintPreview
Sheets("PDF").Visible = True
'Sheets("Fiche").Visible = Sheets("Formulaire").Range("c17") = ""
Sheets("PDF").Visible = True
Me.Show
End Sub
J'en ai profité pour alléger ton code.
 

Bambi35

XLDnaute Occasionnel
Bonsoir Staple1600

Merci pour ton retour

Suite à ton retour j'ai indiqué les cellules de la page "Entree" "A1:B5"
et quand je ferme l'aperçu avant impression je reviens sur la page "Entree" A1:B5
Me.Hide
Range("A1:B5").Select
Range("B5").Activate
ActiveSheet.PageSetup.PrintArea = "$A$1:$H$29"
Application.PrintCommunication = False
With ActiveSheet.PageSetup
etc …………..

Merci encore de ton aide Staple1600
Bambi35

BrunoM45
Sans commentaire

Cordialement au Forum

Bambi35
 

Staple1600

XLDnaute Barbatruc
Re

•>Bambi35
A la place de ActiveSheet, tu peux désigner la feuille par son nom dans ton code VBA.
Exemple
Sheets("Entree").PageSetup.PrintArea = "$A$1:$H$29"
Essaies en remplacant ActiveSheet dans ton code, par le nom de la feuille concernée par la ligne de code VBA.
 

Bambi35

XLDnaute Occasionnel
Bonsoir Staphe1600


Suite à ton retour j'ai fais la modif mais pas de changement
quand je ferme l'aperçu avant impression je reviens sur la page "Entrée" mais la vue sur la page est décalée en (A10:H29)

Me.Hide
Range(A1:H29).Select
Range("H29").Activate
Sheets("Entree").PageSetup.PrintArea = "$A$1:$H$29"
Application.PrintCommunication = False
With ActiveSheet.PageSetup
etc …………..

Merci pour ton retour
Cordialement

B@mbi35
 

Discussions similaires

Statistiques des forums

Discussions
312 109
Messages
2 085 386
Membres
102 880
dernier inscrit
ADEL N