Eric Penfold
Active Member
- Joined
- Nov 19, 2021
- Messages
- 433
- Office Version
- 365
- Platform
- Windows
- Mobile
Using vba form to create Zip folders.
My attempt below using the function code but it says "Argument not optional"?
With this code.
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