Automatisches komprimieren

  • #1
F

freestyler96

Bekanntes Mitglied
Themenersteller
Dabei seit
11.01.2005
Beiträge
114
Reaktionspunkte
0
Ort
Berlin
Hallo an alle,

Ich habe mal wieder ein Problem, zu dem ich bisher keine Lösung finden konnte:

Ich habe einen Rohdatensatz mit vielen, vielen Informationen.
Eine Prozedur arbeitet das ganze auf und erstellt für jeden
einzelnen Mitarbeiter eine Datei. Diese wird dann automatisch
via E-Mail versandt.

Jetzt ist die Datei aber leider noch viel zu groß! Somit suche ich
nach einer Möglichkeit, WinZip mit einzubinden und die Datei direkt
beim Speichern zu komprimieren.

Hat jemand so etwas schon mal gemacht? Geht das überhaupt?
Immerhin ist WinZip kein Office - Programm...

Ich bin mit meinem Latein am Ende.  :|

Vielen Dank für eure Hilfe
 
  • #2
Hallo,

vielleicht mit VBA?

Shell-Aufruf: C:\Programme\Winzip\WINZIP32.EXE -min -a Datei.doc

Grüsse
Wilfried
 
  • #3
Hallo Fibonacci,

in der aktuellen ct ist ein schöner Artikel bzgl. Makro-Programmierung und Nutzung von selbstgebauten Net-Klassen. Unter anderem ist dort auch ein Zip-Klasse enthalten ;)

Gruß Matjes :)
 
  • #4
Hallo,

vielen Dank für den Tip. Mit viel Hilfe sieht meine Lösung nun so aus:

Code:
Declare Function OpenProcess Lib kernel32 _
        (ByVal dwDesiredAccess As Long, _
        ByVal bInheritHandle As Long, _
        ByVal dwProcessId As Long) As Long
Declare Function GetExitCodeProcess Lib kernel32 _
        (ByVal hProcess As Long, _
        lpExitCode As Long) As Long
Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const STILL_ACTIVE = &H103
Public Sub ShellAndWait(ByVal PathName As String, Optional WindowState)
    Dim hProg As Long
    Dim hProcess As Long, ExitCode As Long
    If IsMissing(WindowState) Then WindowState = 1
    hProg = Shell(PathName, WindowState)
    hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, hProg)
    Do
        GetExitCodeProcess hProcess, ExitCode
        DoEvents
    Loop While ExitCode = STILL_ACTIVE
End Sub
Function bIsBookOpen(ByRef szBookName As String) As Boolean
    On Error Resume Next
    bIsBookOpen = Not (Application.Workbooks(szBookName) Is Nothing)
End Function
Function Split97(sStr As Variant, sdelim As String) As Variant
    Split97 = Evaluate({ & _
                       Application.Substitute(sStr, sdelim, ,) & })
End Function
Sub Zip_Selected_File()
    Dim PathWinZip As String, FileNameZip As String, FileName As String
    Dim ShellStr As String, strDate As String, sFileNameXls As String
    Dim vArr As Variant, FileNameXls As Variant
 
    PathWinZip = C:\Programme\WinZip\
    
    strDate = Format(Now,  dd-mm-yy h-mm-ss)
    
    FileNameXls = M:\Angebote\Bar & Lounge Windhorst.xls
 
        vArr = Split97(FileNameXls, \)
        sFileNameXls = vArr(UBound(vArr))

        FileNameZip = M:\ZipArchive\Test.zip
        ShellStr = PathWinZip & Winzip32 -min -a _
                 &   & Chr(34) & FileNameZip & Chr(34) _
                 &   & Chr(34) & FileNameXls & Chr(34)

        ShellAndWait ShellStr, vbHide
    End If
End Sub

Warum und wie es funktioniert hat sich mir zwar noch nicht so ganz erschlossen
aber das wird sicher noch. Auf jeden Fall klappt es so auch ohne XP.

Vielen Dank


Fibo
 
Thema:

Automatisches komprimieren

ANGEBOTE & SPONSOREN

Statistik des Forums

Themen
113.840
Beiträge
707.963
Mitglieder
51.494
Neuestes Mitglied
Flensburg45
Oben