Fix WPS Office VBA 7-Zip Extraction Commands and File Paths
Question details
The user needs to correct VBA code in WPS Office that launches 7-Zip to extract archives, focusing on executable paths, quoting, and command syntax.
- Product
- WPS Office Spreadsheets (VBA)
- Device & OS
- not provided
- Scenario
- Automating ZIP archive extraction from a WPS Office VBA macro by calling the 7-Zip command-line tool.
- Observed behavior
- The macro fails because the 7-Zip executable path, archive paths, quoting, or command syntax is incorrect.
Check the exact installation path of 7-Zip and note whether any archive, destination, or executable path contains spaces. Collect the exact command generated by the VBA code and the error message before testing.
Verify the 7-Zip executable path and quote all file paths before testing the command
Use this when the VBA macro cannot find 7-Zip or when paths with spaces break the command line.
Most 7-Zip failures from VBA are caused by an incorrect executable path, missing quotes around paths with spaces, or command arguments that are not in the order 7-Zip expects.
Before changing the VBA code, test the generated command in Command Prompt to see the exact error returned by 7-Zip.
In WPS Office, press Alt+F11 to open the VBA editor, then expand the workbook project and open the module that contains the 7-Zip extraction code.
Change the executable reference to the full path, for example C:\Program Files\7-Zip\7z.exe, and wrap it in double quotes if the path contains spaces.
Wrap every archive path and destination folder in double quotes, for example "C:\Users\Name\My Archive\file.zip" and "C:\Users\Name\Extracted Files".
Copy the exact command that the VBA code builds, paste it into Command Prompt, run it, and read the error message to confirm the path or syntax issue.
Extract a ZIP archive with the VBA Shell.Application object instead of 7-Zip
Use this alternative when you want a built-in Windows ZIP extraction method that avoids 7-Zip path and command-line quoting entirely.
Use WPS Office VBA to extract ZIP archives without 7-Zip path issues
Open your macro-enabled WPS Spreadsheets file, press Alt+F11, and use either a corrected 7-Zip Shell command or the built-in Shell.Application method. WPS Office supports VBA macros, so you can automate ZIP extraction while working with familiar Excel-compatible .xlsm and .xlsx files.
- 1. Open your workbook in WPS Office: Launch WPS Office, open the macro-enabled workbook, and press Alt+F11 to open the VBA editor.
- 2. Locate or create the extraction macro: In the VBA editor, open the relevant module or insert a new module from the Insert menu.
- 3. Enter the corrected extraction code: Type the VBA code that calls 7-Zip with quoted full paths, or use Shell.Application to copy ZIP items to the destination folder.
- 4. Run and test the macro: Press F5 or click Run to execute the macro, then check the destination folder for extracted files.

Frequently Asked Questions
Why does my VBA 7-Zip command fail with “The system cannot find the file specified”?
This usually means the path to 7z.exe is wrong or is not quoted correctly. Open the VBA editor with Alt+F11, change the executable to the full 7-Zip path such as C:\Program Files\7-Zip\7z.exe, and wrap it in double quotes if it contains spaces.
How do I handle spaces in archive or destination paths in WPS Office VBA?
Wrap every path that contains spaces in double quotes within the command string. For example, use "C:\Users\My Name\Archive.zip" and "C:\Users\My Name\Extracted".
Can I test a VBA-generated 7-Zip command before running the macro?
Yes. Copy the exact command from the VBA code, paste it into Command Prompt, and run it. The error message will show whether the executable path, archive path, quoting, or 7-Zip command syntax is causing the failure.
Is there a way to extract ZIP files from WPS Office VBA without installing 7-Zip?
You can use the Windows Shell.Application object from VBA. Create Shell.Application and use Namespace(destination).CopyHere Namespace(zipPath).Items to extract a standard ZIP archive.
Does WPS Office support VBA macros with 7-Zip and Shell.Application?
WPS Office supports VBA macro editing in WPS Spreadsheets, so you can open the editor with Alt+F11 and use Shell or Shell.Application. Test the macro with a simple archive first to confirm your Windows environment permits the Shell method.




