Re: Prompt to overwrite file
- From: "Bill Mosca, MS Access MVP" <billmosca@xxxxxxxxxx>
- Date: Tue, 27 May 2008 12:33:31 -0700
"Tom Lavedas" <tglbatch@xxxxxxx> wrote in message
news:3ca3e29c-077f-42d6-9b65-61bce5a7ca96@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On May 27, 10:43 am, "Bill Mosca, MS Access MVP"
<billmo...@xxxxxxxxxx> wrote:
Alex, Tom{snip}
Thank you for the detailed response. I may not be able to get to the
user's
machine for a few days due to her schedule but there are things I can
give
you.
I think I might have found the problem in the unzip function, but I'll
let
you all take a look. This If block is written incorrectly (Note the
closing
paren is in the wrong place on line 3). That might be causing the delete
to
fail. The unzip uses Shell which I forgot all about until now.
'Kill file if any exists.
1 For Each varItem In oApp.Namespace(varZipFile).items
2 If fs.FileExists(varTargetFolder & varItem.Name) = True Then
3 fs.DeleteFile(varTargetFolder & varItem.Name), True
4 End If
5 Next
This line is syntactically acceptable ...
fs.DeleteFile(varTargetFolder & varItem.Name), True
You can remove the parentheses altogether without appretiable impact,
but you cannot move the closing paren to the end without generationg a
syntax error ('... subroutines cannot have parentheses ...').
The prompt for confimation is probably due to these statements (around
line 188) ...
'Copy the files in the newly created folder
oApp.Namespace(varTargetFolder).CopyHere
oApp.Namespace(varZipFile).items
NOT where/what you thought/said it was.
I don't know why the delete operation fails (except that there better
not be more than one item in the collection of Items that are returned
by the 'oApp.Namespace(varZipFile).items' part of the statement. I
don't know what the effect would be in the event there were more than
one item.
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
NOT where/what you thought/said it was.
Tom - you are exactly right. After I torn the script apart, I figured it
must be the Unzip routine. I used the script in various versions and had
forgotten I was sending a zipped file due to a slow network.
I changed the line:
fs.DeleteFile(varTargetFolder & varItem.Name), True
- to -
fs.DeleteFile varTargetFolder & varItem.Name, True
and it is working.
The For loop should be deleting one file at a time since it is comparing
file names (no wild cards).
Another bit of code was failing silently:
'Delete temp folder if it exists.
On Error Resume Next
fs.deletefolder Environ("Temp") & "\Temporary Directory*", True
Set oApp = Nothing
I changed it to use GetSpecialFolder and another variable so it now looks
like this (and it works):
'Delete temp folder if it exists.
On Error Resume Next
Set fdr = fs.GetSpecialFolder(TemporaryFolder)
fs.DeleteFolder fdr.Path & "\Temporary Directory*", True
Set fdr = Nothing
Set oApp = Nothing
Now all I have to do is get ahold of the user to test on her PC.
Thank you & Alex for all your help and nudging..
--
Bill Mosca, MS Access MVP
http://www.thatlldoit.com
http://mvp.support.microsoft.com/profile/Bill.Mosca
http://tech.groups.yahoo.com/group/MS_Access_Professionals
.
- Follow-Ups:
- Re: Prompt to overwrite file
- From: Tom Lavedas
- Re: Prompt to overwrite file
- References:
- Prompt to overwrite file
- From: Bill Mosca, MS Access MVP
- Re: Prompt to overwrite file
- From: Alex K. Angelopoulos
- Re: Prompt to overwrite file
- From: Bill Mosca, MS Access MVP
- Re: Prompt to overwrite file
- From: Tom Lavedas
- Re: Prompt to overwrite file
- From: Bill Mosca, MS Access MVP
- Re: Prompt to overwrite file
- From: Alex K. Angelopoulos
- Re: Prompt to overwrite file
- From: Tom Lavedas
- Prompt to overwrite file
- Prev by Date: Re: Prompt to overwrite file
- Next by Date: Re: Prompt to overwrite file
- Previous by thread: Re: Prompt to overwrite file
- Next by thread: Re: Prompt to overwrite file
- Index(es):
Loading