| 12
 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
 
 | Private Sub MiseEnPage(Optional orientation As Byte = xlPortrait)
' Met en page la feuille active. L'utilisation la macro Excel4 PAGE.SETUP() est nettement
' plus rapide, elle envoie tous les arguments en une seule fois alors que PageSetup effectue
' un appel par valeur à définir. Syntaxe :
' PAGE.SETUP(en_tête, pied_pg, marge_gch, marge_dr, marge_haut, marge_bas, no_lig_col,
'            quadrillage, centr_hor, centr_vert, orient, papier, échelle, no_pg, ordre_impr,
'            cellules_nb, qualité, marge_en_tête, marge_pied_pg, annot, brouillon)
'
' Note : Pour afficher la boite de dialogue utiliser PAGE.SETUP?() avec la même syntaxe.
'
' 09/09/08    Patrice             V3-1-03
'
Dim txt As String                 'Texte de la macro Excel4
Dim marge_gauche As String        'Marge gauche
Dim marge_droite As String        'Marge droite
Dim marge_haut As String          'Marge haut
Dim marge_bas As String           'Marge bas
Dim marge_en_tête As String       'Marge en-tête
Dim marge_pied_page As String     'Marge pied de page
 
  'Arrêter l'actualisation automatique de l'écran et les calculs
  Application.ScreenUpdating = False
  Application.Calculation = xlCalculationManual
  'Définir les marges (en cm)
  marge_gauche = Replace(CStr(Application.CentimetersToPoints(0.5) / 72), ",", ".")
  marge_droite = Replace(CStr(Application.CentimetersToPoints(0.5) / 72), ",", ".")
  marge_haut = Replace(CStr(Application.CentimetersToPoints(0.5) / 72), ",", ".")
  marge_bas = Replace(CStr(Application.CentimetersToPoints(1) / 72), ",", ".")
  marge_en_tête = Replace(CStr(Application.CentimetersToPoints(0.5) / 72), ",", ".")
  marge_pied_page = Replace(CStr(Application.CentimetersToPoints(0.4) / 72), ",", ".")
  'Macro Excel 4
  txt = "PAGE.SETUP("
  txt = txt & "" & ","                             'En tête
  txt = txt & """&L" & "&D"                        'Pied de page gauche (date)
  txt = txt & "&C" & "&A"                          'Pied de page centre (feuille)
  txt = txt & "&R" & "Page &P / &N""" & ","        'Pied de page droit (Page page/pages)
  txt = txt & marge_gauche & ","
  txt = txt & marge_droite & ","
  txt = txt & marge_haut & ","
  txt = txt & marge_bas & ","
  txt = txt & "False,False,"                       'En tête ligne & colonne, quadrillage
  txt = txt & "True,False,"                        'Centrage horizontal, vertical
  txt = txt & orientation & ","
  txt = txt & xlPaperA4 & ","                      'Papier
  txt = txt & "100,""Auto"",1,False,,"             'Echelle, no_pg, ordre_impr, N&B, qualité
  txt = txt & marge_en_tête & ","
  txt = txt & marge_pied_page & ")"
  Application.ExecuteExcel4Macro txt
  'Restaurer l'actualisation automatique de l'écran et les calculs
  Application.ScreenUpdating = True
  Application.Calculation = xlCalculationAutomatic
 
End Sub | 
Partager