Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Extracting file from a zip file

I've successfully used Ron de Bruin's useful code for extracting a
file item from a zip file (www.rondebruin.nl/windowsxpunzip.htm).

Now, for completely unknown reasons, the code is failing.

oApp.Namespace(TEMP_FOLDER).CopyHere _
oApp.Namespace(varZipFullPath).Items.Item
(objFile.Name)

When this line of code executes, I get a Windows error (not a VBA
error) saying "the file exists." when the temp folder is in fact
empty. Even if I delete the temp folder and create a new one, this
error message appears. It has me perplexed, as it previously worked
without any such issue.

Any suggestions?

Paul Martin
Melbourne, Australia
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Extracting file from a zip file

Hi Paul

Post more of your code please so we can see more aboy objFile

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Paul Martin" wrote in message ...
I've successfully used Ron de Bruin's useful code for extracting a
file item from a zip file (www.rondebruin.nl/windowsxpunzip.htm).

Now, for completely unknown reasons, the code is failing.

oApp.Namespace(TEMP_FOLDER).CopyHere _
oApp.Namespace(varZipFullPath).Items.Item
(objFile.Name)

When this line of code executes, I get a Windows error (not a VBA
error) saying "the file exists." when the temp folder is in fact
empty. Even if I delete the temp folder and create a new one, this
error message appears. It has me perplexed, as it previously worked
without any such issue.

Any suggestions?

Paul Martin
Melbourne, Australia

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Extracting file from a zip file

Hi Ron, code is below

Paul


Private Sub LoopThruFileItems(ByVal varZipFullPath As Variant)
' From a zip file, extract required data from multiple file items
Dim oApp As Object
Dim objFile As Object
Dim strCSVFullPath As String

Set oApp = CreateObject("Shell.Application")
TEMP_FOLDER = Environ("USERPROFILE") & "\Desktop\TEMP\"

For Each objFile In oApp.Namespace(varZipFullPath).Items
If Left(objFile.Name, 6) = "int140" Then
oApp.Namespace(TEMP_FOLDER).CopyHere _
oApp.Namespace(varZipFullPath).Items.Item(objFile. Name)

' Now I work with the file in the temp folder
End If
Next objFile
End Sub


On Nov 17, 9:22*am, "Ron de Bruin" wrote:
Hi Paul

Post more of your code please so we can see more aboy objFile

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm

"Paul Martin" wrote in ...
I've successfully used Ron de Bruin's useful code for extracting a
file item from a zip file (www.rondebruin.nl/windowsxpunzip.htm).


Now, for completely unknown reasons, the code is failing.


oApp.Namespace(TEMP_FOLDER).CopyHere _
* * * * * * * oApp.Namespace(varZipFullPath).Items.Item
(objFile.Name)


When this line of code executes, I get a Windows error (not a VBA
error) saying "the file exists." *when the temp folder is in fact
empty. Even if I delete the temp folder and create a new one, this
error message appears. *It has me perplexed, as it previously worked
without any such issue.


Any suggestions?


Paul Martin
Melbourne, Australia


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Extracting file from a zip file

FWIW, I've modified the line that was failing with this:

oApp.Namespace(TEMP_FOLDER).CopyHere objFile

It's now working. It's a mystery why it was failing, as the code was
working originally.

Thanks anyway, Ron.

Paul


On Nov 17, 11:28*am, Paul Martin wrote:
Hi Ron, code is below

Paul

Private Sub LoopThruFileItems(ByVal varZipFullPath As Variant)
' From a zip file, extract required data from multiple file items
* * Dim oApp As Object
* * Dim objFile As Object
* * Dim strCSVFullPath As String

* * Set oApp = CreateObject("Shell.Application")
* * TEMP_FOLDER = Environ("USERPROFILE") & "\Desktop\TEMP\"

* * For Each objFile In oApp.Namespace(varZipFullPath).Items
* * * * If Left(objFile.Name, 6) = "int140" Then
* * * * * * oApp.Namespace(TEMP_FOLDER).CopyHere _
* * * * * * * *oApp.Namespace(varZipFullPath).Items.Item(objFile .Name)

* * * * * * ' Now I work with the file in the temp folder
* * * * End If
* * Next objFile
End Sub

On Nov 17, 9:22*am, "Ron de Bruin" wrote:

Hi Paul


Post more of your code please so we can see more aboy objFile


--


Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm


"Paul Martin" wrote in ...
I've successfully used Ron de Bruin's useful code for extracting a
file item from a zip file (www.rondebruin.nl/windowsxpunzip.htm).


Now, for completely unknown reasons, the code is failing.


oApp.Namespace(TEMP_FOLDER).CopyHere _
* * * * * * * oApp.Namespace(varZipFullPath).Items.Item
(objFile.Name)


When this line of code executes, I get a Windows error (not a VBA
error) saying "the file exists." *when the temp folder is in fact
empty. Even if I delete the temp folder and create a new one, this
error message appears. *It has me perplexed, as it previously worked
without any such issue.


Any suggestions?


Paul Martin
Melbourne, Australia


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Extracting file from a zip file

Hi Ron (or anyone else)

The error has just as mysteriously returned, for reasons that I can't
determine (nothing has changed that I'm aware of).

I'm using the line of code as per the previous post, in the block of
code as previously posted. I'm getting a Windows error, "the file
exists."

Any suggestions?

Thanks in advance

Paul


On Nov 17, 12:15*pm, Paul Martin wrote:
FWIW, I've modified the line that was failing with this:

oApp.Namespace(TEMP_FOLDER).CopyHere objFile

It's now working. *It's a mystery why it was failing, as the code was
working originally.

Thanks anyway, Ron.

Paul

On Nov 17, 11:28*am, Paul Martin wrote:

Hi Ron, code is below


Paul


Private Sub LoopThruFileItems(ByVal varZipFullPath As Variant)
' From a zip file, extract required data from multiple file items
* * Dim oApp As Object
* * Dim objFile As Object
* * Dim strCSVFullPath As String


* * Set oApp = CreateObject("Shell.Application")
* * TEMP_FOLDER = Environ("USERPROFILE") & "\Desktop\TEMP\"


* * For Each objFile In oApp.Namespace(varZipFullPath).Items
* * * * If Left(objFile.Name, 6) = "int140" Then
* * * * * * oApp.Namespace(TEMP_FOLDER).CopyHere _
* * * * * * * *oApp.Namespace(varZipFullPath).Items.Item(objFile .Name)


* * * * * * ' Now I work with the file in the temp folder
* * * * End If
* * Next objFile
End Sub


On Nov 17, 9:22*am, "Ron de Bruin" wrote:


Hi Paul


Post more of your code please so we can see more aboy objFile


--


Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm


"Paul Martin" wrote in ...
I've successfully used Ron de Bruin's useful code for extracting a
file item from a zip file (www.rondebruin.nl/windowsxpunzip.htm).


Now, for completely unknown reasons, the code is failing.


oApp.Namespace(TEMP_FOLDER).CopyHere _
* * * * * * * oApp.Namespace(varZipFullPath).Items.Item
(objFile.Name)


When this line of code executes, I get a Windows error (not a VBA
error) saying "the file exists." *when the temp folder is in fact
empty. Even if I delete the temp folder and create a new one, this
error message appears. *It has me perplexed, as it previously worked
without any such issue.


Any suggestions?


Paul Martin
Melbourne, Australia




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Extracting file from a zip file

And it appears that "the file exists." is not because it exists in the
folder I'm defining as the temp folder, but the temp folder - Environ
("Temp") - that the zip file is copied to. It seems I need to include
the lines:

On Error Resume Next
Set FSO = CreateObject("scripting.filesystemobject")
FSO.deletefolder Environ("Temp") & "\Temporary Directory*",
True

Hopefully, this is the last of the error...


On Nov 19, 8:51*am, Paul Martin wrote:
Hi Ron (or anyone else)

The error has just as mysteriously returned, for reasons that I can't
determine (nothing has changed that I'm aware of).

I'm using the line of code as per the previous post, in the block of
code as previously posted. *I'm getting a Windows error, "the file
exists."

Any suggestions?

Thanks in advance

Paul

On Nov 17, 12:15*pm, Paul Martin wrote:

FWIW, I've modified the line that was failing with this:


oApp.Namespace(TEMP_FOLDER).CopyHere objFile


It's now working. *It's a mystery why it was failing, as the code was
working originally.


Thanks anyway, Ron.


Paul


On Nov 17, 11:28*am, Paul Martin wrote:


Hi Ron, code is below


Paul


Private Sub LoopThruFileItems(ByVal varZipFullPath As Variant)
' From a zip file, extract required data from multiple file items
* * Dim oApp As Object
* * Dim objFile As Object
* * Dim strCSVFullPath As String


* * Set oApp = CreateObject("Shell.Application")
* * TEMP_FOLDER = Environ("USERPROFILE") & "\Desktop\TEMP\"


* * For Each objFile In oApp.Namespace(varZipFullPath).Items
* * * * If Left(objFile.Name, 6) = "int140" Then
* * * * * * oApp.Namespace(TEMP_FOLDER).CopyHere _
* * * * * * * *oApp.Namespace(varZipFullPath).Items.Item(objFile .Name)


* * * * * * ' Now I work with the file in the temp folder
* * * * End If
* * Next objFile
End Sub


On Nov 17, 9:22*am, "Ron de Bruin" wrote:


Hi Paul


Post more of your code please so we can see more aboy objFile


--


Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm


"Paul Martin" wrote in ...
I've successfully used Ron de Bruin's useful code for extracting a
file item from a zip file (www.rondebruin.nl/windowsxpunzip.htm).


Now, for completely unknown reasons, the code is failing.


oApp.Namespace(TEMP_FOLDER).CopyHere _
* * * * * * * oApp.Namespace(varZipFullPath).Items.Item
(objFile.Name)


When this line of code executes, I get a Windows error (not a VBA
error) saying "the file exists." *when the temp folder is in fact
empty. Even if I delete the temp folder and create a new one, this
error message appears. *It has me perplexed, as it previously worked
without any such issue.


Any suggestions?


Paul Martin
Melbourne, Australia


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting data into a CSV file Constantly Amazed Excel Programming 0 November 15th 07 12:11 PM
Extracting Custom Views from a File ExcelMonkey Excel Programming 1 March 28th 07 05:52 AM
Extracting data from one xls file and input into another xls file trainerbro Excel Discussion (Misc queries) 1 November 1st 06 08:57 PM
Extracting text from one file to another Vaud Excel Discussion (Misc queries) 1 February 11th 06 09:41 AM
Extracting from another file Marie Excel Programming 5 June 15th 04 12:30 AM


All times are GMT +1. The time now is 10:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"