VBA Site contains VBA code to create macros in WORD EXCEL ACCESS OUTLOOK

 

1) VBA - Archiving files and folders with 7-Zip

 

Excel/Outlook/Access - Zip files/folders optionally wtih password and size of zip parts.

In this example files and folders from given directory will be zipped with password or not.

Additionally archive can be divided into parts with given size f.e. in MB.

 

If needed 7zip programm: http://www.7-zip.org

and some 7ZIP command's instuctions: https://sevenzip.osdn.jp/chm/cmdline/switches/index.htm

 

Sub zip()

Const SOURCE = "C:\YourFolder" 'input path of your folder FROM which folder and files will be zipped

Const DEST = "C:\YourFolder" 'input path of your folder TO which folder and files will be zipped

Zip7Path = "C:\Program Files\7-Zip\7z.exe" 'install 7-zip and input path to exe file

Password = "YourPassword" ' if needed set your password

For Each fold In CreateObject("Scripting.FileSystemObject").GetFolder(SOURCE).subfolders

'pick the method of zipping with:

'zipCommand = Zip7Path & " -v2m" & " -p" & Password & " a -tzip """ & DEST & "\" & fold.Name & ".zip"" """ & fold.path & """" ' pass & 2MB parts

'zipCommand = Zip7Path & " -p" & Password & " a -tzip """ & DEST & "\" & fold.Name & ".zip"" """ & fold.path & """" 'pass

zipCommand = Zip7Path & " a -tzip """ & DEST & "\" & fold.Name & ".zip"" """ & fold.path & """" 'just zip

Shell zipCommand

Next

End Sub

 

1) VBA - UnZip with 7-Zip

 

Sub unzip()

Call Shell("cmd /k cd c:\YourFolder\DestinySubFolder && c:\""Program Files""\7-Zip\7z.exe x C:\SourceFlder\YourZipFile.zip", vbNormalNoFocus)

End Sub



Dodaj komentarz






Dodaj

© 2013-2024 PRV.pl
Strona została stworzona kreatorem stron w serwisie PRV.pl