J
Jacky
Guest
Bonsoir j'ai trouvé cette macro,pour imprimer comme dans Word.
Pour une feuille d'une dizaine de page,la macro fonctionne,par contre quand je passe au dela, la macro bug avec la ligne suivante ((For Each VPB In Wksht.VPageBreaks)) surlignée
Merci pour vtre aide
Sub imprime_la_page_courante()
Dim NoDePage
NoDePage = NumPage(ActiveCell)
ActiveWindow.SelectedSheets.PrintOut From:=NoDePage, To:=NoDePage, Copies:=1
End Sub
Function NumPage(Cellule As Range) As Integer
Dim VPC As Integer, HPC As Integer
Dim VPB As VPageBreak, HPB As HPageBreak
Dim Wksht As Worksheet
Dim Col As Integer, Ligne As Long
Set Wksht = Cellule.Worksheet
Ligne = Cellule.Row
Col = Cellule.Column
If Wksht.PageSetup.Order = xlDownThenOver Then
HPC = Wksht.HPageBreaks.Count + 1
VPC = 1
Else
VPC = Wksht.VPageBreaks.Count + 1
HPC = 1
End If
NumPage = 1
For Each VPB In Wksht.VPageBreaks
If VPB.Location.Column > Col Then Exit For
NumPage = NumPage + HPC
Next VPB
For Each HPB In Wksht.HPageBreaks
If HPB.Location.Row > Ligne Then Exit For
NumPage = NumPage + VPC
Next HPB
End Function
Pour une feuille d'une dizaine de page,la macro fonctionne,par contre quand je passe au dela, la macro bug avec la ligne suivante ((For Each VPB In Wksht.VPageBreaks)) surlignée
Merci pour vtre aide
Sub imprime_la_page_courante()
Dim NoDePage
NoDePage = NumPage(ActiveCell)
ActiveWindow.SelectedSheets.PrintOut From:=NoDePage, To:=NoDePage, Copies:=1
End Sub
Function NumPage(Cellule As Range) As Integer
Dim VPC As Integer, HPC As Integer
Dim VPB As VPageBreak, HPB As HPageBreak
Dim Wksht As Worksheet
Dim Col As Integer, Ligne As Long
Set Wksht = Cellule.Worksheet
Ligne = Cellule.Row
Col = Cellule.Column
If Wksht.PageSetup.Order = xlDownThenOver Then
HPC = Wksht.HPageBreaks.Count + 1
VPC = 1
Else
VPC = Wksht.VPageBreaks.Count + 1
HPC = 1
End If
NumPage = 1
For Each VPB In Wksht.VPageBreaks
If VPB.Location.Column > Col Then Exit For
NumPage = NumPage + HPC
Next VPB
For Each HPB In Wksht.HPageBreaks
If HPB.Location.Row > Ligne Then Exit For
NumPage = NumPage + VPC
Next HPB
End Function