Paramètres d'impression pour un autre classeur
m
Bonjour,
Je fais une macro dans un fichier excel "master". Avec excel, on peut installer cette macro dans le bandeau pour qu'elle soit accessible à partir de n'importe quel excel.
Je cherche donc à instaurer à la feuilles des paramètres d'impression spécifiques. on problème est que je n'arrive pas à cibler la feuille en question. J'ai un userform qui permet de sélectionner un fichier ouvert, afin d'en récupérer le nom. mon code est le suivant:
Sub param_impr()
Dim Fichier
'Sélection du fichier à mettre en forme
Fichier = rechercheFichier()
Workbooks(Fichier).Activate
'sélection de l'imprimante
Application.ActivePrinter = "\\ELBSMS116\ELBPBEA1 sur Ne06:"
Application.PrintCommunication = False
Workbooks(Fichier).Activate
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = ""
Application.PrintCommunication = False
'En-tête
Workbooks(Fichier).Activate
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "&F"
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
'Marges étroites
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA3
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 0
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
End With
Application.PrintCommunication = True
End Sub
La variable Fichier contient le nom exact de mon fichier et je l'active à pas mal d'endroits dans mon code. J'ai remarqué que malgré ça, les paramètres sont tonjours changés dans le fichier master et pas le fichier sélectionné.
Sauriez-vous m'aider ?
merci d'avance,
Cordialement,
Marco