Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
824to828
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
824to828
824to828
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

mail mit lotus mit zip attachment

mail mit lotus mit zip attachment
09.12.2006 15:37:37
Dominik
Hallo
folgendes habe ich:
Ein Macro dass mir das aktuell geöffnete excel-file in eine zip-datei komprimiert, und diese via Lotus Notes versendet.
nun das Problem:
die erste variante die ich hatte war via application.getopenfilename(...) da gibt es schon das erste Problem, es werden mir im fenster das geöffnet wird, werden keine zip Dateien angezeigt, alle anderen Dateien werden angezeigt.
nun das application.get... das gibt mir ein Array zurück, darum habe ich es mit VBA.Array(filenamezip) versucht und das hat leider auch nicht geklappt.
hat da jemand eine Ahnung?
mfg
Dominik

7
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
ZIP-Dateien auswählen und Namen ausgeben
09.12.2006 15:55:16
NoNet
Hallo dominik,
Dein Ansatz mit "Application.GetopenFilename" war schon richtig, evlt, hast Du nur die Argumente falsch gefüllt. Hier ein Beispiel, wie Du MEHRERE ZIP-Dateine auswählen und deren kompletten Pfadnamen ausgeben kannst :
Sub zipAuswahl()
    Dim Dateiname As Variant, msg, z
    Dateiname = Application.GetOpenFilename( _
          FileFilter:="Alle ZIP-Dateien (*.zip), *.zip", _
          Title:="Datei auswählen", MultiSelect:=True)
    If TypeName(Dateiname) = "Boolean" Then
        MsgBox "Keine Datei ausgewählt !"
    Else
        'Dateinamen ausgeben :
        msg = "Es wurden folgende Dateien ausgewählt :" & vbLf & vbLf
        For z = 1 To UBound(Dateiname)
            msg = msg & Dateiname(z) & vbLf
        Next
        MsgBox msg
    End If
End Sub

Anstelle der Ausgabe der Dateinamen kannst Du diese natürlich auch in Dein bereits bestehendes Makro einbauen.
Liebe Grüße,
NoNet
Anzeige
AW: ZIP-Dateien auswählen und Namen ausgeben
09.12.2006 19:09:26
Dominik
Vielen dank nun funktioniert es
mfg
Dominik
AW: ZIP-Dateien auswählen und Namen ausgeben
10.12.2006 11:23:55
Dominik
Leider ist das problemwieder aufgetaucht und ich kann wieder nicht die zip files auswaehlen.
hier mal mein code:
Option Explicit

Private Sub CommandButton1_Click()
Dim strDate As String, DefPath As String, strbody As String
Dim oApp As Object
Dim FileNameZip, FileNameXls
Dim noSession As Object, noDatabase As Object
Dim noDocument As Object, noAttachment As Object
Dim vaFiles As Variant, vaRecipient As Variant
Dim i As Long
Dim Dateiname As Variant, msg, z
Const EMBED_ATTACHMENT = 1454
Const stSubject As String = "For information only"
Const stMsg As String = "with attachment."
'Creat ZIP ##############################################
DefPath = "C:\Temp"
If Right(DefPath, 1) <> "\" Then
DefPath = DefPath & "\"
End If
'Create date/time string and the temporary xls/zip file names
strDate = Format(Now, " dd-mmm-yy h-mm-ss")
FileNameZip = DefPath & Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) & strDate & ".zip"
FileNameXls = DefPath & Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 4) & strDate & ".xls"
If Dir(FileNameZip) = "" And Dir(FileNameXls) = "" Then
'Make copy of the activeworkbook
ActiveWorkbook.SaveCopyAs FileNameXls
'Create empty Zip File
NewZip (FileNameZip)
'Copy the file in the compressed folder
Set oApp = CreateObject("Shell.Application")
oApp.Namespace(FileNameZip).CopyHere FileNameXls
'Keep script waiting until Compressing is done
On Error Resume Next
Do Until oApp.Namespace(FileNameZip).items.Count = 1
Application.Wait (Now + TimeValue("0:00:01"))
Loop
On Error GoTo 0
'Populate the variant-array with recipients.
vaRecipient = VBA.Array("123@123.com")
'Open zip file
vaFiles = Application.GetOpenFilename( _
FileFilter:="Alle ZIP-Dateien (*.zip), *.zip", _
Title:="Datei auswählen", MultiSelect:=False)
'If user(s) cancel the operation.
If Not IsArray(vaFiles) Then Exit Sub
'Instantiate the Lotus Notes COM objects.
Set noSession = CreateObject("Notes.NotesSession")
Set noDatabase = noSession.GETDATABASE("", "")
'Check if mail-database is open or not.
If noDatabase.IsOpen = False Then noDatabase.OPENMAIL
'Instantiate the Lotus E-mailobject.
Set noDocument = noDatabase.CreateDocument
Set noAttachment = noDocument.CreateRichTextItem("Body")
'Add the selected Excel-files to the E-mail.
With noAttachment
For i = 1 To UBound(vaFiles)
.EmbedObject EMBED_ATTACHMENT, "", vaFiles(i)
Next i
End With
'Populate mainproperties of the created E-mail and save & send
'the e-mail.
With noDocument
.Form = "Memo"
.SendTo = vaRecipient
.Subject = stSubject
.Body = stMsg
.SaveMessageOnSend = True
.PostedDate = Now()
.Send 0, vaRecipient
End With
'Release objects from memory.
Set noDocument = Nothing
Set noDatabase = Nothing
Set noSession = Nothing
'Return to Excel.
AppActivate "Microsoft Excel"
MsgBox "The e-mail has successfully been created and sent!", vbInformation
Kill FileNameZip
Kill FileNameXls
End If
End Sub

Sub NewZip(sPath)
'Create empty Zip File
'Changed by keepITcool Dec-12-2005
If Len(Dir(sPath)) > 0 Then Kill sPath
Open sPath For Output As #1
Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
Close #1
End Sub
evtl findest du ja ein fehler oder so
mfg
Dominik
Anzeige
AW: ZIP-Dateien auswählen und Namen ausgeben
10.12.2006 14:47:52
Stefan
Hallo Dominik,
Die Zeile
If Not IsArray(vaFiles) Then Exit Sub
funktioniert nur wenn "MultiSelect:=True" gesetzt ist. Ersetze doch mal "If Not..." mit
If Not vaFiles Then Exit Sub
Schoene Gruesse Stefan
AW: ZIP-Dateien auswählen und Namen ausgeben
10.12.2006 15:54:01
Dominik
ah ja das sollte eigentlich true sein, war nur ein test das ich das auf false geaendert habe.
das komische ist das mit dem Application.GetOpenFilename funktioniert manchmal und manchmal nicht.
AW: ZIP-Dateien auswählen und Namen ausgeben
10.12.2006 17:15:13
Stefan
Hallo Dominik,
Ist Dein Problem damit jetzt noch da oder nicht? Wenn ja, setz Deine Antwort bitte auf "Frage noch offen".
Schoene Gruesse
Stefan
Anzeige
AW: ZIP-Dateien auswählen und Namen ausgeben
10.12.2006 17:32:11
dominik
ah sorry ja die frage ist noch offen

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige