Compressed (zipped) Folder Error - File not found or no read permission

fpskidmark

Board Regular
Joined
Sep 11, 2009
Messages
139
Hi All,


Can anyone please tell me why I'm getting this Compressed (zipped) Folder Error msg "File not found or no read permission" when I run the code below?


Actually, when I run the code on my PC (Operating system - MS Window XP), it works fine, but when my colleague runs it on his PC (MS Window 7) it doesn't work correctly.


The code is supposed to create a zip file then transfers excel files onto the zip file.
When my colleague runs the code, only a few of the excel files are transfers to the Zip file and then he'll get the Compressed (zipped) Folder Error msg.

Any suggestions?

Code:
Sub NewZip(sPath)


'Create empty Zip File
Dim oFSO, arrHex, sBin, i, Zip
  Set oFSO = CreateObject("Scripting.FileSystemObject")
  arrHex = Array(80, 75, 5, 6, 0, 0, 0, _
                 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
  For i = 0 To UBound(arrHex)
    sBin = sBin & Chr(arrHex(i))
  Next
  With oFSO.CreateTextFile(sPath, True)
      .Write sBin
      .Close
  End With


End Sub


Sub Zip_File()


' Copy files to the Zipped File
Dim oApp As Object


On Error Resume Next
Application.DisplayAlerts = False: Windows("OP Report Grid Trend - " & Sheets("MD").Range("A1") & ".xls").Close


NewZip ("P:\OP ZIP Folder\Op Report - " & Sheets("Rafael").Range("F14") & ".zip")
  Set oApp = CreateObject("Shell.Application")
Sheets("MD").Visible = True: Sheets("MD").Select


lastrow = Range("A" & Rows.Count).End(xlUp).Row
On Error Resume Next
For z = 1 To lastrow + 2
oApp.Namespace("P:\OP ZIP Folder\Op Report - " & Workbooks("OP Report Grid Trend").Sheets("Rafael").Range("F14") & ".zip").CopyHere ("P:\MD OP Report\OP Report Grid Trend - " & Workbooks("OP Report Grid Trend").Sheets("MD").Range("A" & z) & ".xls")
Next z
On Error Resume Next
Set oApp = Nothing


lastrow = Range("A" & Rows.Count).End(xlUp).Row
On Error Resume Next
For k = 1 To lastrow + 2
Kill ("P:\MD OP Report\OP Report Grid Trend - " & Workbooks("OP Report Grid Trend").Sheets("MD").Range("A" & k) & ".xls")
Next k


Sheets("MD").Visible = False
Sheets("Rafael").Select
MsgBox ("ZIPPED FILE CREATED")
End Sub

Thank you,
FP
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,213,546
Messages
6,114,256
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top