Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Nov 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Function to create a zipped file (Access 2000)

    Could you help me build a function to create q zip file with the help of Shell ?
    I want to zip the database Sales from the the directory C:BE intoi the directory C:BEarchive.
    Ihave been given the following function but i do not know how to use them:
    Option Compare Database

    Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
    ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) As Long

    Public Const SW_SHOWMAXIMIZED As Long = 3
    Public Const SW_SHOWNORMAL As Long = 1
    Private Const STARTF_USESHOWWINDOW& = &H1
    Private Const NORMAL_PRIORITY_CLASS = &H20&
    Private Const INFINITE = -1&

    Private Type STARTUPINFO
    cb As Long
    lpReserved As String
    lpDesktop As String
    lpTitle As String
    dwX As Long
    dwY As Long
    dwXSize As Long
    dwYSize As Long
    dwXCountChars As Long
    dwYCountChars As Long
    dwFillAttribute As Long
    dwFlags As Long
    wShowWindow As Integer
    cbReserved2 As Integer
    lpReserved2 As Long
    hStdInput As Long
    hStdOutput As Long
    hStdError As Long
    End Type

    Private Type PROCESS_INFORMATION
    hProcess As Long
    hThread As Long
    dwProcessID As Long
    dwThreadID As Long
    End Type

    Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
    hHandle As Long, ByVal dwMilliseconds As Long) As Long

    Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
    lpApplicationName As Long, ByVal lpCommandLine As String, ByVal _
    lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
    ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
    ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
    lpStartupInfo As STARTUPINFO, lpProcessInformation As _
    PROCESS_INFORMATION) As Long

    Private Declare Function CloseHandle Lib "kernel32" (ByVal _
    hObject As Long) As Long
    Public Sub ShellWait(Pathname As String, Optional WindowStyle As Long)
    Dim proc As PROCESS_INFORMATION
    Dim start As STARTUPINFO
    Dim ret As Long
    ' Initialize the STARTUPINFO structure:
    With start
    .cb = Len(start)
    If Not IsMissing(WindowStyle) Then
    .dwFlags = STARTF_USESHOWWINDOW
    .wShowWindow = WindowStyle
    End If
    End With
    ' Start the shelled application:
    ret& = CreateProcessA(0&, Pathname, 0&, 0&, 1&, _
    NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)
    ' Wait for the shelled application to finish:
    ret& = WaitForSingleObject(proc.hProcess, INFINITE)
    ret& = CloseHandle(proc.hProcess)
    End Sub
    '***************** Code End ****************

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Function to create a zipped file (Access 2000)

    The code you posted doesn't have to anything with zipping a file, it is general code that can be used to run another program or command line from VBA.

    Do you have the WinZip® Command Line Add-On? You need a valid license for WinZip Pro to run it (not free)

  3. #3
    New Lounger
    Join Date
    Nov 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Function to create a zipped file (Access 2000)

    Thank you your reply. I have ordered WinPr Pr, i will need it anyway.How should i proceed now for the line to zip the file?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Function to create a zipped file (Access 2000)

    See the threads starting at <post:=580,122>post 580,122</post:>, <post:=517,070>post 517,070</post:>, <post:=517,295>post 517,295</post:>, <post:=514,453>post 514,453</post:> and <post:=303,399>post 303,399</post:>, all started by compatriots of you.

  5. #5
    New Lounger
    Join Date
    Nov 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Function to create a zipped file (Access 2000)

    Thank you very much indeed for your reply.It revolves all to the same problem with us, since the error is again "path not found".I suspect the new winzip 11.1. has changed the names of the files, otherwise i cannot explain myself why is this error . I couldnt find the name Wzzip.exe in the files under C:Program FilesWinZip.May be some other file will do the line ?
    Shell """C:Program FilesWinZipWZzip.exe"" C:BEArchiveBE" & Format(Date, "yyyymmdd") & " C:BE"

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Function to create a zipped file (Access 2000)

    The command-line add-on comes with a help file documenting how to use it. Please look at the examples given there.

  7. #7
    New Lounger
    Join Date
    Nov 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Function to create a zipped file (Access 2000)

    Thank you , i managed it

Posting Permissions

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