Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Excel > Macros et VBA Excel
Macros et VBA Excel Vos questions relatives aux macros Excel, à l'utilisation de VBA et à l'automatisation de vos classeurs Excel.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 03/10/2011, 15h41   #1
Invité de passage
 
Inscription : septembre 2011
Messages : 21
Détails du profil
Informations forums :
Inscription : septembre 2011
Messages : 21
Points : 4
Points : 4
Par défaut Macro pour envoi PDF par courriel

J'ai lu cette discussion.
Merci pour le code
Code :
1
2
3
4
'exporter en format PDF
 ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=dossierSauvegarde & "\" & NomFichier & ".pdf" _
 , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
 :=False, OpenAfterPublish:=False
Est il possible de prendre uniquement un range de cellules ( le même pour chaque feuille du classeur) et l'exporter dans le pdf.
Ambrocbt est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 03/10/2011, 23h44   #2
Expert Confirmé
 
Homme Philippe
ex Observeur CGG / Analyste prog.
Inscription : juin 2006
Messages : 1 704
Détails du profil
Informations personnelles :
Nom : Homme Philippe
Localisation : France, Finistère (Bretagne)

Informations professionnelles :
Activité : ex Observeur CGG / Analyste prog.

Informations forums :
Inscription : juin 2006
Messages : 1 704
Points : 3 625
Points : 3 625
Salut, la réponse est oui, ici dans un seul Pdf résultant, à adapter

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Option Explicit
 
Sub Tsr()
Dim Ws As Worksheet
Dim Ar() As String, i As Long
 
    For Each Ws In ThisWorkbook.Worksheets
        Ws.PageSetup.PrintArea = "$A$1:$D$26"
        ReDim Preserve Ar(i)
        Ar(i) = Ws.Name
        i = i + 1
    Next Ws
 
    Sheets(Ar).Select
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ThisWorkbook.Path & "\" & "Test.pdf" _
                                                               , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
                                                                                                                    :=False, OpenAfterPublish:=False
    Sheets(Ar(0)).Select
    Erase Ar
End Sub
ou feuille par feuille
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Option Explicit
 
Sub Tsr2()
Dim Ws As Worksheet
 
    For Each Ws In ThisWorkbook.Worksheets
        With Ws
            .PageSetup.PrintArea = "$A$1:$D$26"
            .ExportAsFixedFormat Type:=xlTypePDF, Filename:=ThisWorkbook.Path & "\" & Ws.Name & ".pdf" _
                                                            , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
                                                                                                                      :=False, OpenAfterPublish:=False
        End With
    Next Ws
End Sub
__________________
Pensez à Voter, d'avance merci. ( Pouces en bas à la droite de Citer )
Balisez votre code après l'avoir indenté sous Excel via Smart Indenter
Autre utilitaire : MZ Tools 3.0 VBA

Contribution : Excel / Word / PDF avec Adobe Acrobat Pro / PDFCreator 1 2
kiki29 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/10/2011, 10h10   #3
Invité de passage
 
Inscription : septembre 2011
Messages : 21
Détails du profil
Informations forums :
Inscription : septembre 2011
Messages : 21
Points : 4
Points : 4
Merci Kiki, Je viens d'essayer mais je ne génère pas de pdf :/

Voici le code :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Option Explicit
 
Sub pdf()
Dim Ws As Worksheet
Dim Ar() As String, i As Long
 
    For Each Ws In ThisWorkbook.Worksheets
        Ws.PageSetup.PrintArea = "$A$10:$X$39"
        ReDim Preserve Ar(i)
        Ar(i) = Ws.Name
        i = i + 1
    Next Ws
 
    Sheets(Ar).Select
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ThisWorkbook.Path & "C:\Users\utilisateur\Dropbox\Produits strucutrés\Ambroise\Defives\Bonimatif" & "test.pdf" _
                                                               , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
                                                                                                                    :=False, OpenAfterPublish:=False
    Sheets(Ar(0)).Select
 
   Erase Ar
 
End Sub
Ambrocbt est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/10/2011, 10h15   #4
Expert Confirmé
 
Homme Philippe
ex Observeur CGG / Analyste prog.
Inscription : juin 2006
Messages : 1 704
Détails du profil
Informations personnelles :
Nom : Homme Philippe
Localisation : France, Finistère (Bretagne)

Informations professionnelles :
Activité : ex Observeur CGG / Analyste prog.

Informations forums :
Inscription : juin 2006
Messages : 1 704
Points : 3 625
Points : 3 625
Salut, tu m'étonnes regarde ton chemin , encore un drame du copier coller

Code :
Filename:=ThisWorkbook.Path & "C:\Users\utilisateur\Dropbox\Produits strucutrés\Ambroise\Defives\Bonimatif" & "test.pdf"
Ceci devrait t'aller
Code :
Filename:="C:\Users\utilisateur\Dropbox\Produits strucutrés\Ambroise\Defives\Bonimatif" & "\"& "test.pdf"
__________________
Pensez à Voter, d'avance merci. ( Pouces en bas à la droite de Citer )
Balisez votre code après l'avoir indenté sous Excel via Smart Indenter
Autre utilitaire : MZ Tools 3.0 VBA

Contribution : Excel / Word / PDF avec Adobe Acrobat Pro / PDFCreator 1 2
kiki29 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/10/2011, 10h34   #5
Invité de passage
 
Inscription : septembre 2011
Messages : 21
Détails du profil
Informations forums :
Inscription : septembre 2011
Messages : 21
Points : 4
Points : 4
C'est effectivement mieux comme ca.
Merci beaucoup.
Ambrocbt est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 19h29.


 
 
 
 
Partenaires

Hébergement Web