shell function trouble

R

rocco

Hello,
does anyone know why this code wont' work?
Dim zipped As Long
zipped = Shell(CurrentProject.Path & "\7z\7z.exe a -tzip " & "doubts.zip" &
CurrentProject.Path & "\doubts.doc")

I'm trying to zip through the shell function a file (doubt.doc) which is in
the same folder of my database.

The code run, and I can see that the function give me a task Id different
than zero...but... I dont' see any zipped file. I'm going a bit crazy...
Rocco
 
D

Douglas J. Steele

Do you perhaps need a space between doubts.zip and the address to
doubts.doc? Try changing "doubts.zip" to "doubts.zip "
 
R

rocco

I have added the space,
now the code is:
Call Shell(CurrentProject.Path & "\7z\7z.exe a -tzip " & CurrentProject.Path
& "\doubts.zip " & CurrentProject.Path & "\doubts.doc", vbNormalFocus)
...and still don't work.
I don't receive any error messages. But I haven't the zipped file. Nice
thursday evening...
 
P

Peter Martin

Does your currentproject.path have any spaces in it (like 'Program Files')?
It's safer in general to surround them with quotes (three I think, or is it
four?)

HTH - Peter
 
R

rocco

Yes it has.

it is C:\Documents and Settings\rocco n forgione\My Documents\CLIENTS\GRANT

I have tried to manage this issue in this way:

Dim location As String
location = CurrentProject.Path
Call Shell(location & "\7z\7z.exe a -tzip " & location & "\bamba.zip " &
location & "\doubts.doc")


Still nothing happens...
 
R

rocco

To any to may interest: now it works!!
The correct line is:
Call Shell("C:\Program Files\7-Zip\7z a -tzip" & " " & """" &
CurrentProject.Path & "\backup.zip""" & " " & """" & CurrentProject.Path &
"\backup\*""")
(if using 7z like compressing program)

Have to thanks Douglas and Peter for the helpful hints.
Rocco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top