Impression par bouton ajout d'une feuille

Bonjour,

J'ai une macro activer par un bouton afin de faire imprimer la page active en pdf. Cependant, j'aimerais quel inclus une deuxième page (sur un autre onglet) par defaut. l'onglet se nomme (Conditions de contrat). Pouvez-vous m'aider svp ? Voici la macro que j'ai présentement :

Sub Imprimer()
Dim temp1(), temp2()
For Each c In [Zone_d_impression]
If c.Interior.ColorIndex <> xlNone Then
n = n + 1
ReDim Preserve temp1(1 To n)
ReDim Preserve temp2(1 To n)
temp1(n) = c.Address
temp2(n) = c.Interior.ColorIndex
c.Interior.ColorIndex = xlNone
End If
Next c
ActiveSheet.PrintPreview ' ou ActiveSheet.PrintOut
For i = 1 To n
Range(temp1(i)).Interior.ColorIndex = temp2(i)
Next i
End Sub

'Enregistre une copie du classeur Excel dans un dossier spécifié dans les paramètres
Function EnregistrerCopie() As String
Dim dossier As String
Set WshShell = CreateObject("WScript.Shell")
dossier = WshShell.SpecialFolders("MyDocuments")
Dim cheminComplet As String
cheminComplet = dossier & "BC " + CStr(PageRésumé.Range("J2").Value) + CStr(PageRésumé.Range("J5").Value) + ".xlsm"
ActiveWorkbook.SaveCopyAs cheminComplet
EnregistrerCopie = cheminComplet
End Function

Bonjour,

Voici un essai si j'ai bien compris :

Sub ExportPDF()
dim tws() as string
application.screenupdating = false
tws = array(activesheet.name, "Conditions de contrat")
chemin = thisworkbook.path & "\" & tws(0) & " " & format(now, "YYMMDD") & ".pdf"
t = ZoneCouleur(activesheet)
sheets(tws).select
ActiveSheet.exportasfixedformat xltypepdf, chemin, , , false
Recolorier tws(0), t
application.screenupdating = true
End Sub

function ZoneCouleur(Feuille as worksheet)
For Each c In Feuille.[Zone_d_impression]
    If c.Interior.ColorIndex <> xlNone Then
        n = n + 1
        ReDim Preserve temp(1 to 2, 1 To n)
        temp(1, n) = c.Address
        temp(2, n) = c.Interior.ColorIndex
        c.Interior.ColorIndex = xlNone
    End If
Next c
if n > 0 then ZoneCouleur = application.transpose(temp)
end function

Sub Recolorier(NomFeuille$, tableau)
For i = lbound(tableau) To ubound(tableau)
    sheets(NomFeuille).Range(tableau(i, 1)).Interior.ColorIndex = tableau(i, 2)
Next i
end sub

Cdlt,

Je reformule. J'ai un bouton "imprimer" sur une feuille excel. Elle fait imprimer en pdf la page active. Cependant j'aimerais qu'en plus elle imprime un autre onglet nommé "Condition Général". Il faut que je bonifie ma macro, mais je n'y arrive pas...

Sub Imprimer()
Dim temp1(), temp2()
For Each c In [Zone_d_impression]
If c.Interior.ColorIndex <> xlNone Then
n = n + 1
ReDim Preserve temp1(1 To n)
ReDim Preserve temp2(1 To n)
temp1(n) = c.Address
temp2(n) = c.Interior.ColorIndex
c.Interior.ColorIndex = xlNone
End If
Next c
ActiveSheet.PrintPreview ' ou ActiveSheet.PrintOut
For i = 1 To n
Range(temp1(i)).Interior.ColorIndex = temp2(i)
Next i
End Sub

J'attends toujours de l'aide ... svp

Rechercher des sujets similaires à "impression bouton ajout feuille"