Results 1 to 11 of 11

Thread: Resolved - VBA Code to Winzip external File

Hybrid View

  1. #1
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: VBA Code to Winzip external File

    the shell object seems to do this quite well
    vb Code:
    1. p = "c:\test"
    2.       z = p & "\mytest.zip"
    3.       Open z For Output As 1
    4.           Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
    5.       Close 1
    6.       Set sh = CreateObject("shell.application")
    7.       sh.namespace(z).copyhere p
    8.       Set sh = Nothing
    copies all the files in folder test into new zip file in same folder
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  2. #2

    Thread Starter
    Fanatic Member holly's Avatar
    Join Date
    Aug 2002
    Location
    Somewhere on earth
    Posts
    721

    Re: VBA Code to Winzip external File

    Hi

    I have copied your code as below and am still having problems

    HTML Code:
        Dim P As String
        Dim Z As String
        Dim ZipFileName As String
        Dim MyAppID As String
        
        P = filename
        
        If Not Right(P, 4) = ".zip" Then
            P = P & ".zip"
        Else
            P = P & ".CSV"
        End If
        
        Z = P
        
        Open Z For Output As 1
            Print #1, filename
        Close Z
        
       ' MyAppID = Shell("C:\Program Files\WinZip\Winzip.exe", 1)   ' Run
      '  AppActivate MyAppID ' Activate Microsoft
    
        MyAppID = CreateObject("shell.application")
    [COLOR="Red"]    MyAppID = NameSpace(Z).copyhere & P[/COLOR]
    
        
        Set MyAppID = Nothing
    
    End Sub
    I get an error on this line as it states 'Invalid qualifier'

    Pls help!!
    ** HOLLY **

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width