Using Excel 2016 exclusively, is there a way to handle MS Windows prompts which launch during a macro's process?
Edit: I'm unable to use 7zip or WinZip command line as they are not available in the environment. I have access to VBScript, and VBA exclusively. Additional research I found suggested that the Windows Shell does not support unpacking password protected files, so I'm trying to approach this problem by handling the Windows prompts rather than directly handle the zip files.
I have a routine that opens zip files, below, which is being used on password protected zip files. The function works in giving the user the opportunity to enter the password if they're at the keyboard, but I'm looking to increase the automation.
The passwords are deterministic, but I need to handle two different potential windows that can launch as the application runs.
- While extracting the zip file, an undetermined error can occur which can only be bypassed by pressing "Skip", which I can then record in an error log for later.
- When the application works successfully, a prompt for the password appears and I'd like to pass a value into that text field to remove the necessity of human intervention.
Is there a Windows API Excel can connect to to handle these two scenarios, or is there another way for Excel to manage windows?
Thank you for your time! I greatly appreciate any assistance.
Sub UnzipFile(ByRef s_savePath As String, ByRef s_zipName As String)
Dim o_shell As Shell
Dim dbl_i As Double
Dim dbl_count As Double
Dim s_file As String
Set o_shell = CreateObject("Shell.Application")
dbl_count = o_shell.Namespace(s_zipName).Items.Count
If dbl_count > 0 Then
For dbl_i = 0 To dbl_count - 1
o_shell.Namespace(s_savePath).CopyHere o_shell.Namespace(s_zipName).Items.Item(dbl_i)
Next dbl_i
End If
Set o_shell = Nothing
End Sub