/ Published in: Visual Basic

Le code suivant vous permet de copier un fichier (par exemple un document Word ou un PDF) dans une archive existante. Cela implique que le fichier original sera ajouté à l'archive mais restera également dans sa forme originale (non-compressée) à l'endroit d'origine.
Copy a file to an existing archive
Copy a file to an existing archive
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Sub CopierFichierDansArchiveExistant() 'par Excel-Malin.com ( https://excel-malin.com ) '--------------------------------------------------------- 'gestion des erreurs On Error GoTo ErreurCompression 'définition des variables Dim ApplicationArchivage As Object Dim FichierAArchiver, FichierZip 'informations sur les fichiers (chemins & noms) FichierAArchiver = "C:\Test\MonFichierWord.docx" FichierZip = "C:\Test\Archives\MonArchive_1.zip" 'copier le fichier à archiver dans l'archive Set ApplicationArchivage = CreateObject("Shell.Application") ApplicationArchivage.Namespace(FichierZip).CopyHere FichierAArchiver 'Message final MsgBox "L'archivage a été lancé.." Exit Sub ErreurCompression: MsgBox "Une erreur s'est produite..." End Sub
Comments
