'STAMPA TUTTI GLI ALLEGATI DI UNA MAIL



Sub PrintPDFAttachmentsInZip()
    Dim olMail As Outlook.MailItem
    Dim olAttachment As Outlook.attachment
    Dim strTempFolder As String
    Dim objShell As Object
    Dim objFileSystem As Object
    Dim objFile As Object
    Dim startTime As Double
    Dim delayTime As Double
    
    ' Cartella temporanea per l'estrazione dei file ZIP
    strTempFolder = Environ("USERPROFILE") & "\Documents\TempZIP"
    
    ' Crea un oggetto Shell per l'estrazione dei file ZIP
    Set objShell = CreateObject("Shell.Application")
    
    ' Crea un oggetto FileSystem per la gestione dei file
    Set objFileSystem = CreateObject("Scripting.FileSystemObject")
    
    ' Ottieni l'email selezionata
    Set olMail = Application.ActiveExplorer.Selection(1)
    
    ' Cicla attraverso gli allegati dell'email
    For Each olAttachment In olMail.Attachments
        If Right(olAttachment.FileName, 4) = ".zip" Then
            ' Crea la cartella temporanea se non esiste
            If Not objFileSystem.FolderExists(strTempFolder) Then
                objFileSystem.CreateFolder strTempFolder
            End If
            
            ' Salva l'allegato ZIP nella cartella temporanea
            olAttachment.SaveAsFile strTempFolder & "\" & olAttachment.FileName
            
            ' Aggiungi un ritardo prima di cercare i file PDF
            startTime = Timer
            delayTime = 5  ' Modificare se necessario
            
            Do While Timer < startTime + delayTime
                DoEvents
            Loop
            
            ' Estrai il contenuto del file ZIP utilizzando Shell32
            Call ExtractZIPFile(strTempFolder, strTempFolder & "\" & olAttachment.FileName)
            
            ' Cicla attraverso i file estratti
            For Each objFile In objFileSystem.GetFolder(strTempFolder).Files
                If LCase(Right(objFile.Name, 4)) = ".pdf" Then
                    ' Stampa il file PDF
                    Call PrintPDFFile(objFile.Path)
                End If
            Next objFile
            
            ' Elimina il file ZIP
            objFileSystem.DeleteFile strTempFolder & "\" & olAttachment.FileName
        End If
    Next olAttachment
    
    ' Elimina la cartella temporanea
    objFileSystem.DeleteFolder strTempFolder
    
    ' Rilascia gli oggetti
    Set objShell = Nothing
    Set objFileSystem = Nothing
    Set objFile = Nothing
    Set olMail = Nothing
    Set olAttachment = Nothing
End Sub

Sub ExtractZIPFile(ExtractToPath, ZipFilePath)
    Dim objShell32 As Object
    Set objShell32 = CreateObject("Shell.Application")
    
    objShell32.NameSpace(ExtractToPath).CopyHere
    objShell32.NameSpace(ZipFilePath).Items
    
    Set objShell32 = Nothing
End Sub

Sub PrintPDFFile(PDFFilePath)
    Dim objShell As Object
    Set objShell = CreateObject("Shell.Application")
    
    ' Apre il file PDF con l'applicazione predefinita (solitamente Adobe Acrobat Reader)
    objShell.ShellExecute PDFFilePath
    
    ' Attendi un breve periodo prima di stampare
    Application.Wait (Now + TimeValue("00:00:05"))
    
    ' Stampa il file PDF
    objShell.ShellExecute PDFFilePath, "/p", "", "print", 1
    
    Set objShell = Nothing
End Sub

mi da errore qui:  objShell32.NameSpace(ExtractToPath).CopyHere