Mise en forme automatique d'un fichier excel extrait d'une base de données excel

orobert01 Messages postés 7 Date d'inscription mardi 28 mars 2006 Statut Membre Dernière intervention 21 avril 2006 - 28 mars 2006 à 15:06
orobert01 Messages postés 7 Date d'inscription mardi 28 mars 2006 Statut Membre Dernière intervention 21 avril 2006 - 28 mars 2006 à 15:45
Je copie le résultat d'un état d'access vers excel à partir d'une macro access. Par contre je voudrais avoir par défaut une mise en forme à l'ouverture du fichier excel résultant. J'avais déja créé la macro Excel pour cette mise en page mais comme mon fichier est écrasé à chaque fois, il faudrait idéalement que je rajoute ce code dans ma macro access. J'ai esayé mais cela ne fonctionne pas...
Voici mon code excel que j'aimerai faire apparaitre

Sub mef_extracts()
'
' mef_extracts Macro
' Macro enregistrée le 04/07/2005 par MSCHALL
'
' Touche de raccourci du clavier: Ctrl+Maj+M
'
Rows("1:1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 90
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Cells.Select
Cells.EntireColumn.AutoFit
Rows("1:1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Replace What:="_", Replacement:=" ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.RowHeight = 25
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlGreater, _
Formula1:="0"
With Selection.FormatConditions(1).Font
.Bold = True
.Italic = False
.ColorIndex = 2
End With
With Selection.FormatConditions(1).Borders(xlLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.FormatConditions(1).Borders(xlRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.FormatConditions(1).Borders(xlTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.FormatConditions(1).Borders(xlBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.FormatConditions(1).Interior.ColorIndex = 41
With Selection.Font
.Name = "Arial"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Selection.AutoFilter
Range("D2").Select
ActiveWindow.FreezePanes = True
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
.PrintTitleColumns = "$A:$C"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = "&8&D &T"
.CenterHeader = "&8&F" & Chr(10) & "&""Arial,Gras""&A"
.RightHeader = "&8ADT"
.LeftFooter = "&8Direction Technique"
.CenterFooter = ""
.RightFooter = "&""Arial,Normal""&8Page &P / &N"
.LeftMargin = Application.InchesToPoints(0.4)
.RightMargin = Application.InchesToPoints(0.4)
.TopMargin = Application.InchesToPoints(0.6)
.BottomMargin = Application.InchesToPoints(0.24)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.1)
.PrintHeadings = False
.PrintGridlines = True
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
End Sub

2 réponses

fred.toto Messages postés 73 Date d'inscription mardi 10 avril 2001 Statut Membre Dernière intervention 4 mars 2009
28 mars 2006 à 15:30
Sur Office 2003 en mettant l'autofilter en commentaire ca marche.
Il faut voir ce que tu veux mettre comme paramètre à ton autofilter si tu souhaites le conserver
Fred.
0
orobert01 Messages postés 7 Date d'inscription mardi 28 mars 2006 Statut Membre Dernière intervention 21 avril 2006
28 mars 2006 à 15:45
Ou se situe l'autofilter dans ce code? et à quoi sert'il vraiment (mise a part a filtrer automatiquement...)?

Olivier
0
Rejoignez-nous