Need to create zip folders

Eric Penfold

Active Member
Joined
Nov 19, 2021
Messages
433
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Using vba form to create Zip folders.
My attempt below using the function code but it says "Argument not optional"?
With this code.
VBA Code:
CreateZipFile = (strPath & "\" & strPath & "\" & strFolder & "\" & Int(cmbdata(0).Zip))

VBA Code:
Function CreateZipFile(ZipPath As Variant, ZipFileName As Variant)

          Open ZipFileName For Output As #1
          Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
          Close #1
          
          ShellApp.Namespace(ZipFileName).copyhere ShellApp.Namespace(ZipPath).Items
          
          On Error Resume Next
          Do Until ShellApp.Namespace(ZipFileName).Items.Count = ShellApp.Namespace(ZipPath).Items.Count
          Application.Wait (Now + TimeValue("0:00:01"))
          Loop
          On Error GoTo 0

End Function
Private Sub ZipCreator_Click()

    Dim Subpath As String
    Dim cmbdata
    Dim strFolder As String
    Dim strPath As String
    Dim ShellApp As Object
    
    cmbdata = Split(Me.OpenDrawing.Value, "-")
     cmbdata(0) = Replace(cmbdata(0), "-", "")

        Subpath = "S:\R&D\Drawing Nos" & "\" & Sub_Path & ""
         strPath = Subpath & "\" & Int(cmbdata(0))
          strFolder = Dir(strPath, vbDirectory)
          
  CreateZipFile = (strPath & "\" & strPath & "\" & strFolder & "\" & Int(cmbdata(0).Zip))
          
End Sub
 
Hi Eric. Your getting the error because the CreateZipFile function requires 2 arguments ie. CreateZipFile(ArgA as Variant, ArgB as Variant). To invoke this function...
VBA Code:
Call CreateZipFile(Folder path to zip, Zip file name/path)
I would suggest that you
VBA Code:
msgbox strfolder & "\" & strpath
msgbox strfolder & "\" & Int(cmbdata(0).Zip)
Make sure the folder path and zip file name/path are correct. HTH. Dave
 
Upvote 0
Now says Run-time error 75
on code below
VBA Code:
Open ZipFileName For Output As #1
How could i solve this?
 
Upvote 0

Forum statistics

Threads
1,226,836
Messages
6,193,247
Members
453,783
Latest member
Chandni

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