Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Created a short macro to unzip some files, and start a clock after a commandbutton is pressed. I am on a network, with some restrictions, but I do have admin rights to both this computer and the network folder. Problem is, it acts ok in the spreadsheet or when it's stepped through, but it does not unzip my files. Any ideas?

Sub Start()
CommandButton3_Click
End Sub
Private Sub CommandButton3_Click()
Const SZP As String = ("7z.exe")
Dim Cmd$
Dim Pth As String
Pth = Application.ActiveWorkbook.Path & "\"
Cmd$ = Pth & SZP & " e " & ("Myfiles.zip") & " -o " & Pth
'On Error Resume Next
Shell (Cmd$)
Range("D4").Value = Now
Sheets("Q1").Select
Range("a1").Select
End Sub
Sub Stp()
CommandButton4_Click
End Sub
Private Sub CommandButton4_Click()
Range("D5").Value = Now
End Sub

What I have tried:

I've tried just about everything I can think of.

Thanks in advance

Bob Williams
Posted
Updated 18-Aug-16 14:55pm
Comments
Mohibur Rashid 18-Aug-16 19:50pm    
question is, do you have 7z.exe in your application active workbook path?
Mohibur Rashid 18-Aug-16 20:24pm    
Also, you have space after -o
the example command
"C:\Program Files\7-Zip\7z.exe" e LexAndYaccTutorial.7z -oC:\Users\crook\Desktop\

and also use -y switch to ensure that overwrite happens properly.

Just figured it out!!!

I needed to define the CMD$ as follows:

Cmd$ = Pth & SZP & " e " & Pth & ("MyFiles.zip") & " -o" & Pth

Then changed the Shell (CMD$) to Call Shell (CMD$)

One thing that helped was I first changed the Call Shell Line to:

Call Shell ("CME.exe /S / K" & " " & CMD$)

That pulled up the Dos Command Box and left it there so I could see what errors were there.

Thanks for the opportunity to vent!
 
Share this answer
 
Comments
Mohibur Rashid 18-Aug-16 20:28pm    
I opened the window long time ago, and just uploaded a comment :)
Are you sure its CME.exe? not CMD.exe?
Thanks, you are right, it was CMD not CME.

Bob
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900