Word Publipostage, word et pdf

LONAPA

XLDnaute Nouveau
Bonjour,
je souhaite pouvoir envoyer rapidement des attestations à une centaine de personnes.
Les attestations sont format word.
J'utilise la fonction publipostage pour les remplir et les envoyer automatiquement à partir d'une base tirée d'un fichier excel.
Mais je souhaiterais que cette attestation sont envoyée au format pdf et word pour qu'elle ne soit pas modifiée par ailleurs.
pouvez vous m'aider ?
 

kiki29

XLDnaute Barbatruc
Salut, avec PDFCreator 1.7.3 en adaptant ceci à ton contexte pour un PDF crypté via AES 128 avec mots de passe utilisateur/propriétaire.

VB:
Option Explicit

Private Sub CrypterPDF(ByVal sNomfichier As String, ByVal sOutput As String)
Dim pdf As Object, Crypt As Object

    Set Crypt = CreateObject("pdfforge.Pdf.PDFEncryptor")

    With Crypt
        .AllowAssembly = False
        .AllowCopy = False
        .AllowFillIn = False
        .AllowModifyAnnotations = False
        .AllowModifyContents = False
        .AllowPrinting = True
        .AllowPrintingHighResolution = True
        .AllowScreenreaders = False
        .EncryptionMethod = 2
        .ownerPassword = "master"
        .userPassword = "user"
    End With

    Set pdf = CreateObject("pdfforge.Pdf.Pdf")
    pdf.EncryptPDFFile sNomfichier, sOutput, Crypt
    Set pdf = Nothing

    Set Crypt = Nothing
End Sub

Sub SelFichierACrypter_AES_128()
Dim Fichier As Variant, FSO As Object, sNom as String
    ChDir ThisWorkbook.Path
    Application.StatusBar = ""
    Fichier = Application.GetOpenFilename("Fichiers PDF (*.Pdf), *.Pdf", Title:="Sélection PDF")
    If Fichier = False Then Exit Sub
    DoEvents
  
    Set FSO = CreateObject("Scripting.FileSystemObject")
    sNom = FSO.GetBaseName(Fichier)
    Set FSO = Nothing

    CrypterPDF Fichier, ThisWorkbook.Path & "\" & sNom & "_AES.Pdf"
    Application.StatusBar = "Terminé"
End Sub
 

Pièces jointes

  • 1.png
    1.png
    21.2 KB · Affichages: 62
  • 2.png
    2.png
    11.8 KB · Affichages: 53
Dernière édition:

LONAPA

XLDnaute Nouveau
Bonjour,
Je travaille dans une entreprise ou l'installation de logiciel est très encadré, et on ne peux installer PDF Creator.
On se contente d'office 365 et acrobat reader.
Avec office 365 on peut sauvegarder en pdf, mais je ne trouve pas comment intégrer cette fonction dans publipostage AVANT l'envoi des attestations.
 

kiki29

XLDnaute Barbatruc
Re, eh bien, tu peux dire au muttawa de ta boîte : pas de bras ... pas de chocolat. Sans PDFCreator 1.7.3. la procédure CrypterPDF n'est pas utilisable et de toute façon Acrobat Reader d'aucune utilité.
 
Dernière édition:

LONAPA

XLDnaute Nouveau
@kiki29 Finallement nous avons PDF Créator V1.6.2. Cela pourrait peut être faire l'affaire !?!
Par contre, coté programmation VBA si n'y connais rien.
Peux tu m'expliquer avec un pas à pas et le fichier joint comment je pourrais m'y prendre ?
Les champs nom, prénom, adresse... seraient tirés d'un fichier excel.
Le but étant toujours de pouvoir remplir et envoyer ce document enregistré sous pdf automatiquement avec la fonction publipostage.
Merci de ton aide.
 

Pièces jointes

  • attestation.docx
    18 KB · Affichages: 10

soan

XLDnaute Barbatruc
Inactif
Bonjour @LONAPA, kiki29,

Je ne m'y connaît pas bien là-dessus ; pourtant, il me semble bien que c'est comme ça :

1) c'est avec ta version de Word que tu fais une conversion du doc Word en pdf ;
c'est possible dès la version 2010 ; voir ce lien (cliquer sur le lien bleu) ; comme
tu connais déjà cela, tout ce point 1) est pour d'autres lecteurs de ce sujet.

2) comme la conversion en pdf a déjà été faite au point 1) à partir de Word,
le logiciel PDFCreator 1.7.3 n'est plus nécessaire pour faire la conversion
de .docx en .pdf ; par contre, selon @kiki29, il reste obligatoire pour faire
le cryptage ; c'est l'même principe avec ton PDFCreator 1.6.2 (s'il fait lui
aussi du cryptage).

3) peut-être que ça serait possible de crypter le fichier .pdf (converti à partir
de Word) avec un autre logiciel de cryptage de fichier (plus général) ? lien
sur plusieurs logiciels de chiffrement (= cryptage) ; attention : regarde bien
« Licence : » (Gratuit, Shareware, OpenSource, ou Demo) ; regarde aussi
« OS : » (Operating Sytem = Système d'exploitation = Windows, ou Linux) ;
« Langue : » (EN = English = en Anglais ; FR = French = en Français).

j'ai rien d'autre à proposer ; je laisse la suite à kiki29,
ou à un autre intervenant du forum.


soan
 
Dernière édition:

LONAPA

XLDnaute Nouveau
La version de word nous permet de sauvegarder en PDF.
Mais en utilisant la fonction publipostage, arrivé à Terminer et fusionner, puis Envoyer des courriers...
word joint automatiquement le fichier sauvegardé en *.doc. Ce que l'on ne souhaite pas. On veut que word l'envoi au format *.pdf
Nul besoin de crypter quoique ce soit.
 

soan

XLDnaute Barbatruc
Inactif
LONAPA à dit:
Nul besoin de crypter quoique ce soit.

ah, ok ; c'est le post #4 de kiki29 qui m'avait fait penser que tu voulais aussi crypter
le fichier pdf ; je le cite : « pas de bras ... pas de chocolat. Sans PDFCreator 1.7.3.
la procédure CrypterPDF n'est pas utilisable ».

@kiki29 : faut pas m'induire en erreur comme ça, lollllll ! :p (moi j'ai des bras ;
j'ai droit aux chocolats ? miam !!! :D)


soan
 

kiki29

XLDnaute Barbatruc
LONAPA
Mais je souhaiterais que cette attestation sont envoyée au format pdf et word pour qu'elle ne soit pas modifiée par ailleurs.
Salut, eh bien avec Acrobat ( pas le Reader ) tu peux modifier un pdf sans problème, crypté cela devient disons plus difficile. Pour cela, si tu as PDFCreator 1.7.3, il te faudra appeler CrypterPDF en adaptant SelFichierACrypter_AES_128 à ton contexte Word.
 

Pièces jointes

  • 1.png
    1.png
    72.4 KB · Affichages: 37
Dernière édition:

Staple1600

XLDnaute Barbatruc
Bonsoir le fil

Si il s'agit une fois le publipostage effectué de générer N fichiers PDF (1 par enregistrement présent dans la base de données)
Voir ce fil (pas si vieux)
 

kiki29

XLDnaute Barbatruc
Re, je persiste avec 2 versions Woard et PDFCreator 1.7.3
VB:
Option Explicit

Private Sub CrypterPDF(ByVal sNomfichier As String, ByVal sOutput As String)
Dim pdf As Object, Crypt As Object

    Set Crypt = CreateObject("pdfforge.Pdf.PDFEncryptor")

    With Crypt
        .AllowAssembly = False
        .AllowCopy = False
        .AllowFillIn = False
        .AllowModifyAnnotations = False
        .AllowModifyContents = False
        .AllowPrinting = True
        .AllowPrintingHighResolution = True
        .AllowScreenreaders = False
        .EncryptionMethod = 2
        .ownerPassword = "master"
        .userPassword = ""
    End With

    Set pdf = CreateObject("pdfforge.Pdf.Pdf")
    pdf.EncryptPDFFile sNomfichier, sOutput, Crypt
    Set pdf = Nothing

    Set Crypt = Nothing
End Sub

Sub Test_01()
Dim Fichier As Variant, FSO As Object, sNom As String
Dim FD As FileDialog

    Application.StatusBar = ""

    Set FD = Application.FileDialog(msoFileDialogOpen)
    With FD
        .InitialFileName = ThisDocument.Path & "\"
        If .Show = -1 Then
            Fichier = FD.SelectedItems(1)
        Else
            Exit Sub
        End If
    End With

    Set FSO = CreateObject("Scripting.FileSystemObject")
    sNom = FSO.GetBaseName(Fichier)
    Set FSO = Nothing

    CrypterPDF Fichier, ThisDocument.Path & "\" & sNom & "_AES.Pdf"
    Application.StatusBar = "Terminé"
End Sub

Sub Test_02()
Dim Fichier As Variant, FSO As Object, sNom As String

    Fichier = "C:\...\...\Catalogue.pdf"

    Set FSO = CreateObject("Scripting.FileSystemObject")
    sNom = FSO.GetBaseName(Fichier)
    Set FSO = Nothing

    CrypterPDF Fichier, ThisDocument.Path & "\" & sNom & "_AES.Pdf"
End Sub
 
Dernière édition:

Discussions similaires

Statistiques des forums

Discussions
311 722
Messages
2 081 930
Membres
101 843
dernier inscrit
Thaly