Saliou MBALO
XLDnaute Nouveau
Bonjour la famille,
j'essaie d'exécuter mon code pour envoyer un mail mais je bute sur une erreur dont je n'arrive pas à résoudre.
"erreur d'execution 91 variable objet ou variable de bloc with non définie"
		
		
	
	
		
	
Je mets le code à votre disposition pour aide svp.
En vous remerciant d'avance.
	
	
	
	
	
		
	
		
			
		
		
	
				
			j'essaie d'exécuter mon code pour envoyer un mail mais je bute sur une erreur dont je n'arrive pas à résoudre.
"erreur d'execution 91 variable objet ou variable de bloc with non définie"
Je mets le code à votre disposition pour aide svp.
En vous remerciant d'avance.
		VB:
	
	
	Option Explicit
Sub Mail()
Dim Destinataire As String
Dim objMessage As Object
Dim sNomPdf As String
Dim sDossier As String
Dim sNomCrypt As String
    sDossier = ThisWorkbook.Path
    Destinataire = "mymail@domain.com"
    sNomPdf = sDossier & "\" & "BSI 2019.pdf"
    Feuil1.ExportAsFixedFormat _
            Type:=xlTypePDF, _
            Filename:=sNomPdf, _
            Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, _
            IgnorePrintAreas:=False, _
            OpenAfterPublish:=False
    sNomCrypt = sDossier & "\" & "Tempo.pdf"
    EncryptPDFUsingPdfforgeDll sNomPdf, sNomCrypt
    Kill sNomPdf
    Name sNomCrypt As sNomPdf
         Set objMessage = objMessage.CreateItem(0)
      With objMessage
          .From = "mymail@domain.com"
          .To = Destinataire
          .CC = ""
          .BCC = ""
          .Subject = "Essai"
          .Body = "Bonjour, ceci est un test"
          .AddAttachment sNomPdf
          .Send
      End With
    Set objMessage = Nothing
End Sub
Private Sub EncryptPDFUsingPdfforgeDll(sNomFichier As String, sOutputCrypt 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 = "saliou"
        .UserPassword = "master"
    End With
    Set Pdf = CreateObject("pdfforge.pdf.pdf")
    Pdf.EncryptPDFFile sNomFichier, sOutputCrypt, Crypt
    Set Pdf = Nothing
    Set Crypt = Nothing
End Sub
	
			
				Dernière édition: